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/
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'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 :
I am adding property information to our MSI built using WiX 3.11. I am referring to the properties you find when right-clicking on a file and selecting Properties:
In the Product.wxs file I am setting these values like so:
<Product Id="$(var.ProductCode)"
Name="$(var.ProductName) $(var.ShortAssyVersion)"
Language="1033"
Version="$(var.LongAssyVersion)"
Manufacturer="$(var.CompanyLegalName)"
UpgradeCode="$(var.UpgradeCode)">
<Package Description="Installation Package"
InstallerVersion="300"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
Comments="$(var.LongAssyVersion)" />
I would like to use some of these values in an automated build script and am trying to retrieve the values using PowerShell get-item. When I run this command in PowerShell:
PS C:\Subversion\MyProduct\Publish> (get-item "Setup.msi").VersionInfo | fl
this is the output:
OriginalFilename :
FileDescription :
ProductName :
Comments :
CompanyName :
FileName : C:\Subversion\MyProduct\Publish\Setup.msi
FileVersion :
ProductVersion :
IsDebug : False
IsPatched : False
IsPreRelease : False
IsPrivateBuild : False
IsSpecialBuild : False
Language :
LegalCopyright :
LegalTrademarks :
PrivateBuild :
SpecialBuild :
FileVersionRaw : 0.0.0.0
ProductVersionRaw : 0.0.0.0
How can I retrieve these values (i.e., Comments, Date Created, etc.) from the file properties for use in a PowerShell script?
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.
I am trying to query a registry path of a remote server:
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired"
This contains a list of all updates that are pending a reboot (REG_DWORD), and perhaps some dates of some kind. I am interested in the number of pending updates only.
Performing the following PS cmdlet, I do not get the result I expect in querying the reg path:
$Computer = "Server01"
$HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] “\\$Computer\root\default:StdRegProv”
$RegRR = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired")
$RegRR =
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
sNames :
However, as a test, if I query the path one key before this, excluding "\RebootRequired" then this works and I can then query the sValues.
$RegRR = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
sNames : {Power, RequestedAppCategories, Results, RebootRequired...}
Ultimately, I wish to query this reg key in order to return back the number of updates pending a reboot, existing DWORD records. There is a RebootRequiredSince date, which at first could be useful, but found out that not all of our servers have this (mix of 2008 R2 and 2012).
Any ideas?
Thanks
Make sure you enable the RemoteRegistry Service on the target machine, then you can try:
$Computer = "RemoteComputerName"
$RootKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$Computer)
$SubKey = $RootKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\RebootRequired")
To get all the available values you can do:
$SubKey.GetValueNames()
To get all the Subkey Names:
$SubKey.GetSubKeyNames()
To get Specific value:
$SubKey.GetValue("ValueName")
To Get the Default Key Value:
$SubKey.GetValue($null)