public UpdateFabricUpgradeRequest(IFabricClient fabricClient, FabricUpgradeUpdateDescription updateDescription, TimeSpan timeout) : base(fabricClient, timeout) { ThrowIf.Null(updateDescription, "updateDescription"); this.UpdateDescription = updateDescription; }
protected void UpdateClusterUpgrade(FabricUpgradeUpdateDescription updateDescription) { var clusterConnection = this.GetClusterConnection(); try { clusterConnection.UpdateFabricUpgradeAsync( updateDescription, this.GetTimeout(), this.GetCancellationToken()).Wait(); this.WriteObject(this.FormatOutput(updateDescription), true); } catch (AggregateException aggregateException) { aggregateException.Handle((ae) => { this.ThrowTerminatingError( ae, Constants.UpdateClusterUpgradeErrorId, clusterConnection); return(true); }); } }
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); } }