protected void AddToPSObject(PSObject itemPSObj, ClusterUpgradeHealthPolicy upgradeHealthPolicy) { if (upgradeHealthPolicy == null) { return; } itemPSObj.Properties.Add(new PSNoteProperty(Constants.MaxPercentDeltaUnhealthyNodesPropertyName, upgradeHealthPolicy.MaxPercentDeltaUnhealthyNodes)); itemPSObj.Properties.Add(new PSNoteProperty(Constants.MaxPercentUpgradeDomainDeltaUnhealthyNodesPropertyName, upgradeHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes)); }
new internal static unsafe MonitoredRollingFabricUpgradePolicyDescription FromNative(IntPtr policyPtr) { if (policyPtr == IntPtr.Zero) { return(null); } var castedPtr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION *)policyPtr; var monitoringPolicy = new MonitoredRollingFabricUpgradePolicyDescription(); if (castedPtr->Reserved != IntPtr.Zero) { var castedEx1Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX1 *)castedPtr->Reserved; if (castedEx1Ptr->MonitoringPolicy != IntPtr.Zero) { monitoringPolicy.MonitoringPolicy = RollingUpgradeMonitoringPolicy.FromNative(castedEx1Ptr->MonitoringPolicy); } if (castedEx1Ptr->HealthPolicy != IntPtr.Zero) { monitoringPolicy.HealthPolicy = ClusterHealthPolicy.FromNative(castedEx1Ptr->HealthPolicy); } if (castedEx1Ptr->Reserved != IntPtr.Zero) { var castedEx2Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX2 *)castedEx1Ptr->Reserved; monitoringPolicy.EnableDeltaHealthEvaluation = NativeTypes.FromBOOLEAN(castedEx2Ptr->EnableDeltaHealthEvaluation); if (castedEx2Ptr->UpgradeHealthPolicy != IntPtr.Zero) { monitoringPolicy.UpgradeHealthPolicy = ClusterUpgradeHealthPolicy.FromNative(castedEx2Ptr->UpgradeHealthPolicy); } if (castedEx2Ptr->Reserved != IntPtr.Zero) { var castedEx3Ptr = (NativeTypes.FABRIC_ROLLING_UPGRADE_POLICY_DESCRIPTION_EX3 *)castedEx2Ptr->Reserved; if (castedEx3Ptr->ApplicationHealthPolicyMap != IntPtr.Zero) { monitoringPolicy.ApplicationHealthPolicyMap.FromNative(castedEx3Ptr->ApplicationHealthPolicyMap); } } } } monitoringPolicy.FromNativeHelper(policyPtr); return(monitoringPolicy); }
protected override void ProcessRecord() { try { if (this.ReplicaQuorumTimeoutSec.HasValue) { this.WriteWarning(StringResources.PowerShell_ReplicaQuorumTimeoutSec_Deprecated); if (!this.UpgradeReplicaSetCheckTimeoutSec.HasValue) { this.UpgradeReplicaSetCheckTimeoutSec = this.ReplicaQuorumTimeoutSec.Value; } } if (this.RestartProcess) { this.WriteWarning(StringResources.PowerShell_RestartProcess_Deprecated); if (!this.ForceRestart) { this.ForceRestart = this.RestartProcess; } } RollingUpgradePolicyDescription upgradePolicyDescription; if (this.Monitored) { var monitoringPolicy = new RollingUpgradeMonitoringPolicy(); if (this.FailureAction != UpgradeFailureAction.Invalid) { monitoringPolicy.FailureAction = this.FailureAction; } if (this.HealthCheckRetryTimeoutSec.HasValue) { monitoringPolicy.HealthCheckRetryTimeout = TimeSpan.FromSeconds(this.HealthCheckRetryTimeoutSec.Value); } if (this.HealthCheckWaitDurationSec.HasValue) { monitoringPolicy.HealthCheckWaitDuration = TimeSpan.FromSeconds(this.HealthCheckWaitDurationSec.Value); } if (this.HealthCheckStableDurationSec.HasValue) { monitoringPolicy.HealthCheckStableDuration = TimeSpan.FromSeconds(this.HealthCheckStableDurationSec.Value); } if (this.UpgradeDomainTimeoutSec.HasValue) { monitoringPolicy.UpgradeDomainTimeout = TimeSpan.FromSeconds(this.UpgradeDomainTimeoutSec.Value); } if (this.UpgradeTimeoutSec.HasValue) { monitoringPolicy.UpgradeTimeout = TimeSpan.FromSeconds(this.UpgradeTimeoutSec.Value); } var monitoredPolicyDescription = new MonitoredRollingFabricUpgradePolicyDescription { UpgradeMode = RollingUpgradeMode.Monitored, ForceRestart = this.ForceRestart, MonitoringPolicy = monitoringPolicy }; upgradePolicyDescription = monitoredPolicyDescription; if (this.IsUpdatingHealthPolicy()) { if (!this.Force && !this.IsHealthPolicyComplete() && !this.ShouldProcess( //// description shows up for "-WhatIf" string.Format( CultureInfo.InvariantCulture, "{0} {1}", StringResources.PowerShell_HealthPolicyUpgradeCaption, StringResources.PowerShell_ClusterHealthPolicyUpdateWarning), //// warning and caption show up when prompting for confirmation StringResources.PowerShell_ClusterHealthPolicyUpdateWarning, StringResources.PowerShell_HealthPolicyUpgradeCaption)) { return; } var healthPolicy = new ClusterHealthPolicy(); if (this.ConsiderWarningAsError.HasValue) { healthPolicy.ConsiderWarningAsError = this.ConsiderWarningAsError.Value; } if (this.MaxPercentUnhealthyApplications.HasValue) { healthPolicy.MaxPercentUnhealthyApplications = this.MaxPercentUnhealthyApplications.Value; } if (this.MaxPercentUnhealthyNodes.HasValue) { healthPolicy.MaxPercentUnhealthyNodes = this.MaxPercentUnhealthyNodes.Value; } if (this.ApplicationTypeHealthPolicyMap != null) { foreach (var entry in this.ApplicationTypeHealthPolicyMap) { healthPolicy.ApplicationTypeHealthPolicyMap.Add(entry.Key, entry.Value); } } monitoredPolicyDescription.HealthPolicy = healthPolicy; } monitoredPolicyDescription.EnableDeltaHealthEvaluation = this.EnableDeltaHealthEvaluation; if (this.IsUpdatingUpgradeHealthPolicy()) { if (!this.Force && !this.IsUpgradeHealthPolicyComplete() && !this.ShouldProcess( //// description shows up for "-WhatIf" string.Format( CultureInfo.InvariantCulture, "{0} {1}", StringResources.PowerShell_HealthPolicyUpgradeCaption, StringResources.PowerShell_ClusterUpgradeHealthPolicyUpdateWarning), //// warning and caption show up when prompting for confirmation StringResources.PowerShell_ClusterUpgradeHealthPolicyUpdateWarning, StringResources.PowerShell_HealthPolicyUpgradeCaption)) { return; } var upgradeHealthPolicy = new ClusterUpgradeHealthPolicy(); if (this.MaxPercentDeltaUnhealthyNodes.HasValue) { upgradeHealthPolicy.MaxPercentDeltaUnhealthyNodes = this.MaxPercentDeltaUnhealthyNodes.Value; } if (this.MaxPercentUpgradeDomainDeltaUnhealthyNodes.HasValue) { upgradeHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes = this.MaxPercentUpgradeDomainDeltaUnhealthyNodes.Value; } monitoredPolicyDescription.UpgradeHealthPolicy = upgradeHealthPolicy; } if (this.ApplicationHealthPolicyMap != null) { foreach (var entry in this.ApplicationHealthPolicyMap) { monitoredPolicyDescription.ApplicationHealthPolicyMap.Add(entry.Key, entry.Value); } } } else if (this.UnmonitoredManual) { upgradePolicyDescription = new RollingUpgradePolicyDescription { UpgradeMode = RollingUpgradeMode.UnmonitoredManual, ForceRestart = this.ForceRestart, }; } else { upgradePolicyDescription = new RollingUpgradePolicyDescription { UpgradeMode = RollingUpgradeMode.UnmonitoredAuto, ForceRestart = this.ForceRestart, }; } if (this.UpgradeReplicaSetCheckTimeoutSec.HasValue) { upgradePolicyDescription.UpgradeReplicaSetCheckTimeout = TimeSpan.FromSeconds(this.UpgradeReplicaSetCheckTimeoutSec.Value); } var upgradeDescription = new FabricUpgradeDescription { UpgradePolicyDescription = upgradePolicyDescription, TargetCodeVersion = this.CodePackageVersion, TargetConfigVersion = this.ClusterManifestVersion }; this.UpgradeCluster(upgradeDescription); } catch (Exception exception) { this.ThrowTerminatingError( exception, Constants.UpgradeClusterErrorId, null); } }
protected override void ProcessRecord() { try { var updateDescription = new FabricUpgradeUpdateDescription(); if (this.ForceRestart.HasValue) { updateDescription.ForceRestart = this.ForceRestart.Value; } if (this.UpgradeReplicaSetCheckTimeoutSec.HasValue) { updateDescription.UpgradeReplicaSetCheckTimeout = TimeSpan.FromSeconds(this.UpgradeReplicaSetCheckTimeoutSec.Value); } if (this.UpgradeMode.HasValue) { updateDescription.UpgradeMode = this.UpgradeMode.Value; } if (this.FailureAction.HasValue) { updateDescription.FailureAction = this.FailureAction.Value; } if (this.HealthCheckWaitDurationSec.HasValue) { updateDescription.HealthCheckWaitDuration = TimeSpan.FromSeconds(this.HealthCheckWaitDurationSec.Value); } if (this.HealthCheckStableDurationSec.HasValue) { updateDescription.HealthCheckStableDuration = TimeSpan.FromSeconds(this.HealthCheckStableDurationSec.Value); } if (this.HealthCheckRetryTimeoutSec.HasValue) { updateDescription.HealthCheckRetryTimeout = TimeSpan.FromSeconds(this.HealthCheckRetryTimeoutSec.Value); } if (this.UpgradeTimeoutSec.HasValue) { updateDescription.UpgradeTimeout = TimeSpan.FromSeconds(this.UpgradeTimeoutSec.Value); } if (this.UpgradeDomainTimeoutSec.HasValue) { updateDescription.UpgradeDomainTimeout = TimeSpan.FromSeconds(this.UpgradeDomainTimeoutSec.Value); } if (this.IsUpdatingHealthPolicy()) { if (!this.Force && !this.IsHealthPolicyComplete() && !this.ShouldProcess( //// description shows up for "-WhatIf" string.Format( CultureInfo.InvariantCulture, "{0} {1}", StringResources.PowerShell_HealthPolicyUpdateCaption, StringResources.PowerShell_ClusterHealthPolicyUpdateWarning), //// warning and caption show up when prompting for confirmation StringResources.PowerShell_ClusterHealthPolicyUpdateWarning, StringResources.PowerShell_HealthPolicyUpdateCaption)) { return; } var healthPolicy = new ClusterHealthPolicy(); if (this.ConsiderWarningAsError.HasValue) { healthPolicy.ConsiderWarningAsError = this.ConsiderWarningAsError.Value; } if (this.MaxPercentUnhealthyApplications.HasValue) { healthPolicy.MaxPercentUnhealthyApplications = this.MaxPercentUnhealthyApplications.Value; } if (this.MaxPercentUnhealthyNodes.HasValue) { healthPolicy.MaxPercentUnhealthyNodes = this.MaxPercentUnhealthyNodes.Value; } if (this.ApplicationTypeHealthPolicyMap != null) { foreach (var entry in this.ApplicationTypeHealthPolicyMap) { healthPolicy.ApplicationTypeHealthPolicyMap.Add(entry.Key, entry.Value); } } updateDescription.HealthPolicy = healthPolicy; } if (this.EnableDeltaHealthEvaluation.HasValue) { updateDescription.EnableDeltaHealthEvaluation = this.EnableDeltaHealthEvaluation.Value; } if (this.IsUpdatingUpgradeHealthPolicy()) { if (!this.Force && !this.IsUpgradeHealthPolicyComplete() && !this.ShouldProcess( //// description shows up for "-WhatIf" string.Format( CultureInfo.InvariantCulture, "{0} {1}", StringResources.PowerShell_HealthPolicyUpdateCaption, StringResources.PowerShell_ClusterUpgradeHealthPolicyUpdateWarning), //// warning and caption show up when prompting for confirmation StringResources.PowerShell_ClusterUpgradeHealthPolicyUpdateWarning, StringResources.PowerShell_HealthPolicyUpdateCaption)) { return; } var upgradeHealthPolicy = new ClusterUpgradeHealthPolicy(); if (this.MaxPercentDeltaUnhealthyNodes.HasValue) { upgradeHealthPolicy.MaxPercentDeltaUnhealthyNodes = this.MaxPercentDeltaUnhealthyNodes.Value; } if (this.MaxPercentUpgradeDomainDeltaUnhealthyNodes.HasValue) { upgradeHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes = this.MaxPercentUpgradeDomainDeltaUnhealthyNodes.Value; } updateDescription.UpgradeHealthPolicy = upgradeHealthPolicy; } updateDescription.ApplicationHealthPolicyMap = this.ApplicationHealthPolicyMap; this.UpdateClusterUpgrade(updateDescription); } catch (Exception exception) { this.ThrowTerminatingError( exception, Constants.UpdateClusterUpgradeErrorId, null); } }