Im doing deployments from Jenkins job using powershell. THe job will be sucessful and the deployment starts on the cluster, but sometimes that fails and rollsback in which case I don't get notification of it.
Is there a way to monitor the upgrade from my jenkins job using a powershell cmdlet to poll the status or some way to know if it completed with a success or failure?
No clue if there is a smarter way, but you can get the upgrade state for a given application using the "Get-ServiceFabricApplicationUpgrade" cmdlet.
Get-ServiceFabricApplicationUpgrade -ApplicationName fabric:/your/awesomeApp
By pure coincidence i have an upgrade running on our cluster just now, and you get and output like the following (i have adjusted some names parameters etc):
ApplicationName : fabric:/your/awesomeApp
ApplicationTypeName : YourAwesomeApp.FabricType
TargetApplicationTypeVersion : 2017.1005.2-r20.1
ApplicationParameters : { "Param1" = "Value1";
"Param2" = "Value2";
"ActorService_MinReplicaSetSize" = "2";
"ActorService_PartitionCount" = "1";
"ActorService_TargetReplicaSetSize" = "3";
}
StartTimestampUtc : 05.10.2017 08.49.39
UpgradeState : RollingForwardInProgress
UpgradeDuration : 00:09:01
CurrentUpgradeDomainDuration : 00:00:00
NextUpgradeDomain : 4
UpgradeDomainsStatus : { "3" = "InProgress";
"0" = "Completed";
"1" = "Completed";
"2" = "Completed";
"4" = "Pending" }
UpgradeKind : Rolling
RollingUpgradeMode : Monitored
FailureAction : Rollback
ForceRestart : False
UpgradeReplicaSetCheckTimeout : 49710.06:28:15
HealthCheckWaitDuration : 00:00:00
HealthCheckStableDuration : 00:02:00
HealthCheckRetryTimeout : 00:10:00
UpgradeDomainTimeout : 00:30:00
UpgradeTimeout : 01:00:00
ConsiderWarningAsError :
MaxPercentUnhealthyPartitionsPerService :
MaxPercentUnhealthyReplicasPerPartition :
MaxPercentUnhealthyServices :
MaxPercentUnhealthyDeployedApplications :
ServiceTypeHealthPolicyMap :
This will also report if it is in a rollback state.
It might be interesting to figure out if you can get a callback/event or something from the Health Monitoring, because that is basically what causes the upgrade to rollback.
Related
Service Fabric Versions:
Runtime - 9.0.1028.9590
SDK - 6.0.1028.9590
When moving a Service Fabric service instance to a new Service Fabric Application instance of the same Application Type, we reuse the Fabric URI as it existed under the original application under which it was created. However, the new service instance is reporting its health status to the original application, rather than to the new application. Below is a synthetic example that replicates our issue as it appears in our development environments (both OneBox and an actual Service Fabric cluster):
Initial Conditions:
Application Types:
A.B.Type
Applications:
fabric:/A/B (hosting fabric:/A/B/C/D)
Services:
fabric:/A/B/C/D (hosted under fabric:/A/B)
Process (Note: all steps are done either via PowerShell Service Fabric Module or Service Fabric Explorer, both produce identical results):
Create an identical Application instance from the existing Application Type but with a modified name (fabric:/A/B/C)
Remove the existing service (fabric:/A/B/C/D) from the originating application (fabric:/A/B)
Recreate the service using the same name (fabric:/A/B/C/D) under the new application (fabric:/A/B/C)
Observe the health reporting for the new service is reported back to the originating application (fabric:/A/B)
Final Conditions:
Application Types:
A.B.Type
Applications:
fabric:/A/B (hosting no services)
fabric:/A/B/C (hosting fabric:/A/B/C/D)
Services:
fabric:/A/B/C/D (hosted under fabric:/A/B/C, but service health and service/replica information reported to fabric:/A/B)
The recreated (new service with reused name) service knows it is being hosted under the new application:
Get-ServiceFabricServiceDescription -ServiceName 'fabric:/A/B/C/D'
ApplicationName : fabric:/A/B/C
ServiceName : fabric:/A/B/C/D
ServiceTypeName : Web1Type
ServiceKind : Stateful
HasPersistedState : True
MinReplicaSetSize : 3
TargetReplicaSetSize : 3
The new service reports its own health correctly:
Get-ServiceFabricServiceHealth -ServiceName 'fabric:/A/B/C/D'
ServiceName : fabric:/A/B/C/D
AggregatedHealthState : Ok
PartitionHealthStates :
PartitionId : 6a2ecddb-0f26-4703-8141-0dcaf80faa67
AggregatedHealthState : Ok
HealthEvents :
SourceId : System.FM
Property : State
HealthState : Ok
SequenceNumber : 504
SentAt : 9/19/2022 20:41:39
ReceivedAt : 9/19/2022 20:42:00
TTL : Infinite
Description : Service has been created.
RemoveWhenExpired : False
IsExpired : False
HealthReportID : FM_7.0_1008
Transitions : Warning->Ok = 9/19/2022 20:42:00, LastError = 1/1/0001 00:00:00
HealthStatistics :
Replica : 3 Ok, 0 Warning, 0 Error
Partition : 1 Ok, 0 Warning, 0 Error
The applications are not reporting the correct health (original application):
Get-ServiceFabricApplicationHealth -ApplicationName 'fabric:/A/B'
ApplicationName : fabric:/A/B
AggregatedHealthState : Ok
ServiceHealthStates :
ServiceName : fabric:/A/B/C/D
AggregatedHealthState : Ok
DeployedApplicationHealthStates : None
HealthEvents :
SourceId : System.CM
Property : State
HealthState : Ok
SequenceNumber : 52266
SentAt : 9/19/2022 20:39:38
ReceivedAt : 9/19/2022 20:39:38
TTL : Infinite
Description : Application has been created.
RemoveWhenExpired : False
IsExpired : False
HealthReportID : CM_7.0_1000
Transitions : Warning->Ok = 9/19/2022 20:39:38, LastError = 1/1/0001 00:00:00
HealthStatistics :
Replica : 3 Ok, 0 Warning, 0 Error
Partition : 1 Ok, 0 Warning, 0 Error
Service : 1 Ok, 0 Warning, 0 Error
DeployedApplication : 0 Ok, 0 Warning, 0 Error
DeployedServicePackage : 0 Ok, 0 Warning, 0 Error
New application:
Get-ServiceFabricApplicationHealth -ApplicationName 'fabric:/A/B/C'
ApplicationName : fabric:/A/B/C
AggregatedHealthState : Ok
ServiceHealthStates : None
DeployedApplicationHealthStates :
ApplicationName : fabric:/A/B/C
NodeName : _Node_0
AggregatedHealthState : Ok
ApplicationName : fabric:/A/B/C
NodeName : _Node_3
AggregatedHealthState : Ok
ApplicationName : fabric:/A/B/C
NodeName : _Node_1
AggregatedHealthState : Ok
HealthEvents :
SourceId : System.CM
Property : State
HealthState : Ok
SequenceNumber : 52289
SentAt : 9/19/2022 20:41:26
ReceivedAt : 9/19/2022 20:41:26
TTL : Infinite
Description : Application has been created.
RemoveWhenExpired : False
IsExpired : False
HealthReportID : CM_7.0_1000
Transitions : Warning->Ok = 9/19/2022 20:41:26, LastError = 1/1/0001 00:00:00
HealthStatistics :
Service : 0 Ok, 0 Warning, 0 Error
Replica : 0 Ok, 0 Warning, 0 Error
Partition : 0 Ok, 0 Warning, 0 Error
DeployedServicePackage : 3 Ok, 0 Warning, 0 Error
DeployedApplication : 3 Ok, 0 Warning, 0 Error
The service is actively reporting its health. Attempts to send updated health reports using either Send-ServiceFabricApplicationHealthReport or Send-ServiceFabricServiceHealthReport do not produce corrected results.
Creating subsequent new service instances under either application (without removing and recreating) result in correct health and service/replica reporting.
Question Is this a bug or is this scenario of reusing a service name that previously existed under another application not supported?
I am trying to access the metadata in a .msg file using Powershell (for example, get the sender address, subject line etc)
I have the following, simple code
Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$outlook = New-Object -comObject Outlook.Application
$msg = $outlook.Session.OpenSharedItem("C:\Test\email.msg")
but I get the error
You cannot call a method on a null-valued expression. At line:4 char:1
If I run
$outlook
I get
Application :
Class :
Session :
Parent :
Assistant :
Name :
Version :
COMAddIns :
Explorers :
Inspectors :
LanguageSettings :
ProductCode :
AnswerWizard :
FeatureInstall :
Reminders :
DefaultProfileName :
IsTrusted :
Assistance :
TimeZones :
PickerDialog :
all the properties appear to be null, including .Session, which explains why I get the null value error.
What have I done wrong in creating the $outlook object?
I have tried with both Outlook running and not running and the same happens.
I have Office 365 installed and I'm using Powershell 5.1.19041.1320
I managed to fix this issue by doing a "Quick Repair" of O365 in the programs and features dialog
On Windows 10 Pro and "Microsoft 365 Apps for Business," Quick Repair also worked for me 7/15/2022 when my similar script which creates a CVS export of selected Outlook Contacts stopped working, for the same reason, namely that the assignment to $outlook completed normally, but then $outlook had no parameter values, just as you show above, leading to the same null-valued expression error.
I had not run the script for a month or more, so can't say which or what kind of update broke it.
Here is an example of a valid value for $outlook, after repair (I set Product Code to all 0s in case that value identifies my license):
Application : Microsoft.Office.Interop.Outlook.ApplicationClass
Class : olApplication
Session : Microsoft.Office.Interop.Outlook.NameSpaceClass
Parent :
Assistant : System.__ComObject
Name : Outlook
Version : 16.0.0.15330
COMAddIns : System.__ComObject
Explorers : {}
Inspectors : {System.__ComObject, System.__ComObject, System.__ComObject, System.__ComObject...}
LanguageSettings : System.__ComObject
ProductCode : {00000000-0000-0000-0000-000000000000}
AnswerWizard :
FeatureInstall : msoFeatureInstallOnDemand
Reminders : {$null, $null, $null, $null...}
DefaultProfileName : MS-2017-10
IsTrusted : False
Assistance : System.__ComObject
TimeZones : {System.__ComObject, System.__ComObject, System.__ComObject, System.__ComObject...}
PickerDialog : System.__ComObject
I'm trying to make a dynamic multiple selection menu via powershell, based on data imported via a CSV file.
After importing objects via CSV, and try to add multiple filters on the SEL and RESTART fields and on their values. I see a strange behavior of the counter, to count the number of objects which are conform the different conditions/filters.
It seems that counting 01 returns no display ... suggestion, ideas (I've it also done with one filtering ... same problem)
## MENU
$csvFilePathMENU=CheckFileExcist –FileName $csvFileMENU -FilePath $csvPathMENU
# import the objects ... and put it into a variable
$global:menus = Import-Csv $csvFilePathMENU
$global:nrElemsMENU=$menus.Count
write-output "$($nrElemsMENU)"
I tried two different ways ... to filter
$nrRestarts=$($menus | Where-Object {( $_.RESTART -as [int] -eq 1 )} | Where-Object {( $_.SEL -as [int] -eq 1 )} ).count
write-host "nrRestarts : ", $nrRestarts
$nrRestarts2=$($menus | Where {( $_.RESTART -as [int] -eq 1 ) -and ( $_.SEL -as [int] -eq 1 )}).count
write-host "nrRestarts : ", $nrRestarts2
[I've tried it with several combinations]
left side picture
INPUT CSV 01 : where SEL and RESTART are 1
MENU : MEINBERG
SEL : 1
RESTART : 1
...
MENU : NTP
SEL : 1
RESTART : 1
RESULT 01 :
nrRestarts : 2
nrRestarts : 2
right side picture
INPUT CSV 02 : where SEL and RESTART are 1
MENU : NTP
SEL : 1
RESTART : 1
RESULT 02 :
nrRestarts :
nrRestarts :
WRONG/NO RESULT ... ??? 01 ???
any body a suggestion?
In the Windows Powershell ISE ... the feedback
PS C:\Users\Administrator> $nrElemsMENU
9
PS C:\Users\Administrator> $menus
MENU : anti-virus : Windows-Defender
info : Windows-Defender has to be uninstalled, before installing an other anti-virus program
function : Windows-Defender
status : -1
SEL : 0
RESTART : 0
FUNC : stopWindowsDefender
PARENT : Anti-virus
MENU : Windows 'ServerStandard'
info : Windows has to be upgraded if working with an EVALUATION prod key
function :
status : -1
SEL : 0
RESTART : 1
FUNC :
PARENT :
MENU : F-SEC
info : F-SEC has to be configured as an isolated machine on the CSI server
function : F-SEC
status : -1
SEL : 0
RESTART : 0
FUNC : startFSec
PARENT :
MENU : NTP
info : disable default Windows NTP service
function :
status : -1
SEL : 1
RESTART : 0
FUNC :
PARENT : NTP
MENU : MEINBERG
info : disable default Windows NTP service
function :
status : -1
SEL : 0
RESTART : 1
FUNC :
PARENT :
MENU : NTP
info : disable default Windows NTP service
function :
status : -1
SEL : 1
RESTART : 1
FUNC :
PARENT :
MENU : openssl
info : disable default Windows NTP service
function :
status : -1
SEL : 0
RESTART : 0
FUNC :
PARENT : OpenSSL
MENU : execute
info :
function :
status : -1
SEL : 0
RESTART : 1
FUNC :
PARENT :
MENU : quite
info :
function :
status : -1
SEL : 0
RESTART : 1
FUNC :
PARENT :
We have started using DSC to deploy some applications. We are pushing out the configurations and only want it to run this configuration once and then stop. However it seems that if a configuration fails we end up with a pending configuration which DSC seems to keep attempting to reapply. Is this intended behavior? Is there anyway for us to prevent this happening.
Here are our LCM settings
ActionAfterReboot : ContinueConfiguration
AgentId : 4314CBF5-928E-11E5-941E-00155D0****
AllowModuleOverWrite : True
CertificateID : EBB297F164BDA1C1A7918C12C31D0F70110****
ConfigurationDownloadManagers : {[ConfigurationRepositoryWeb]DSCHTTP}
ConfigurationID : 3fa96bab-ac50-4b80-a9ac-384bfd*****
ConfigurationMode : ApplyOnly
ConfigurationModeFrequencyMins : 15
Credential :
DebugMode : {NONE}
DownloadManagerCustomData :
DownloadManagerName :
LCMCompatibleVersions : {1.0, 2.0}
LCMState : Idle
LCMStateDetail :
LCMVersion : 2.0
StatusRetentionTimeInDays : 10
PartialConfigurations :
RebootNodeIfNeeded : True
RefreshFrequencyMins : 30
RefreshMode : Push
ReportManagers : {}
ResourceModuleManagers : {[ResourceRepositoryWeb]DSCHTTP}
PSComputerName : D6B*****01
PSComputerName : D6B*****01
Here is a blog that explains how LCM behaves and how you can get out of it http://nanalakshmanan.github.io/blog/Converging-to-a-desired-state/
All, I am trying to deploy my cloud service to Windows Azure. Currently It works fine. But I still try to understand the detail inside of it . Like below Power Shell script.
The script is trying to get the status of a deplpoyment in the Staging slot after New-AzureDeployment has been executed successfully.
while ($True) {
$deployment = Get-AzureDeployment -ServiceName $CloudServiceName -Slot Staging
if ($deployment.Status -ne 'Running') {
continue
}
$notReadyList = $deployment.RoleInstanceList | Where-Object InstanceStatus -ne 'ReadyRole'
if (!$notReadyList) {
break
}
$errorStatusList = #('RestartingRole';'CyclingRole';'FailedStartingRole';'FailedStartingVM';'UnresponsiveRole')
$errorList = $notReadyList | Where-Object InstanceStatus -in $errorStatusList
if ($errorList) {
throw 'Role in staging fail to start for some of these reasons:' + ($errorList | Format-List | Out-String)
}
Start-Sleep -Seconds 10
}
I have some questions about the script . Please try to help me .thanks.
What is the object type of Get-AzureDeployment return ? I search it in the Help Doc. But did't found any information about it.
How many possible status except Running the Get-AzureDeployment could return ?
Is there any possibility never break in the loop ?
Thanks.
What is the object type of Get-AzureDeployment return ? I search it in
the Help Doc. But did't found any information about it.
As mentioned in the documentation, this operation returns an object of type DeploymentInfoContext. You can find more about this object here: https://github.com/WindowsAzure/azure-sdk-tools/blob/master/WindowsAzurePowershell/src/Commands.ServiceManagement/Model/DeploymentInfoContext.cs. However if you look at the source code for Get-AzureDeployment here: https://github.com/WindowsAzure/azure-sdk-tools/blob/master/WindowsAzurePowershell/src/Commands.ServiceManagement/HostedServices/GetAzureDeployment.cs, you'll notice that it returns the following:
return new DeploymentInfoContext(d)
{
OperationId = s.Id,
OperationStatus = s.Status.ToString(),
OperationDescription = CommandRuntime.ToString(),
ServiceName = this.ServiceName
};
How many possible status except Running the Get-AzureDeployment could
return ?
You can find the list of possible statuses here: http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx.
Following is copied from the link above:
Is there any possibility never break in the loop ?
I'm not sure about that. I guess you will need to test it out thoroughly. The statuses may change with the newer versions of Service Management API so you would need to ensure that your code covers all possible statuses.
Get-AzureDeployment returns an object of schema shown below
SdkVersion :
RollbackAllowed : False
Slot : Production
Name :
DeploymentName : [Somename]
Url : http://[Somename].cloudapp.net/
Status : Suspended
CurrentUpgradeDomain : 0
CurrentUpgradeDomainState :
UpgradeType :
RoleInstanceList : {}
Configuration :
DeploymentId : [SomeGUID]
Label : [Somename]
VNetName : [Somename]
DnsSettings :
OSVersion :
RolesConfiguration : {[[Somename], Microsoft.WindowsAzure.Commands.ServiceManagement.Model.RoleConfiguration]}
ServiceName : [Somename]
OperationDescription : Get-AzureDeployment
OperationId : 1801bce8-73b4-5a74-9e80-e03d04ff405b
OperationStatus : Succeeded