/// <summary> /// Get the progress of the current upgrade /// </summary> /// <param name="timeout"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <FabricOrchestrationUpgradeProgress> ProcessGetClusterConfigurationUpgradeProgressAsync(TimeSpan timeout, CancellationToken cancellationToken) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessGetUpgradeProgressAsync."); FabricOrchestrationUpgradeProgress upgradeProgress = null; try { string configVersion = await this.GetCurrentJsonConfigVersionAsync(this.cancellationToken).ConfigureAwait(false); FabricUpgradeProgress fabricUpgradeProgress = await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync( () => this.fabricClient.ClusterManager.GetFabricUpgradeProgressAsync(Constants.UpgradeServiceMaxOperationTimeout, this.cancellationToken), Constants.UpgradeServiceMaxOperationTimeout, this.cancellationToken).ConfigureAwait(false); ConfigUpgradeErrorDetail errorDetails = await this.storeManager.GetConfigUpgradeErrorDetailsAsync(Constants.ConfigUpgradeErrorDetails, cancellationToken); uint manifestVersion; upgradeProgress = new FabricOrchestrationUpgradeProgress() { UpgradeState = fabricUpgradeProgress.UpgradeState, ProgressStatus = uint.TryParse(fabricUpgradeProgress.TargetConfigVersion, out manifestVersion) ? manifestVersion : 0, ConfigVersion = configVersion, Details = (errorDetails != null) ? errorDetails.ToString() : null }; } catch (Exception e) { UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessGetUpgradeProgressAsync exception: {0}", e); throw; } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Exiting ProcessGetUpgradeProgressAsync."); return(upgradeProgress); }
public async Task PersistConfigUpgradeErrorDetailsAsync(string key, ConfigUpgradeErrorDetail errorDetails, CancellationToken cancellationToken) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Enter PersistConfigUpgradeErrorDetailsAsync."); var clusterStateTable = await this.stateManager.GetOrAddAsync <IReliableDictionary <string, string> >(Constants.ClusterReliableDictionaryName); try { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Serialize errorDetails into string format."); string errorDetailsString = JsonConvert.SerializeObject( errorDetails, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize, NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.Objects, TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full }); using (var tx = this.stateManager.CreateTransaction()) { ConditionalValue <string> existingData = await clusterStateTable.TryGetValueAsync(tx, key, Constants.DefaultDictionaryTimeout, cancellationToken).ConfigureAwait(false); if (existingData.HasValue) { bool success = await clusterStateTable.TryUpdateAsync( tx, key, errorDetailsString, existingData.Value).ConfigureAwait(false); if (!success) { UpgradeOrchestrationTrace.TraceSource.WriteWarning( TraceType, "SetStorageObjectAsync: UpgradeErrorDetails data is not updated. The reason is {0}", string.Equals(errorDetailsString, existingData.Value, StringComparison.OrdinalIgnoreCase) ? "the value is not changed." : "to be investigated."); return; } } else { await clusterStateTable.AddAsync( tx, key, errorDetailsString, Constants.DefaultDictionaryTimeout, cancellationToken).ConfigureAwait(false); } await tx.CommitAsync().ConfigureAwait(false); } } catch (Exception e) { UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "PersistConfigUpgradeErrorDetailsAsync: {0}", e.ToString()); throw; } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Exit PersistConfigUpgradeErrorDetailsAsync."); }
public async Task <ConfigUpgradeErrorDetail> GetConfigUpgradeErrorDetailsAsync(string key, CancellationToken cancellationToken) { ConfigUpgradeErrorDetail configUpgradeErrorDetails = null; var clusterStateTable = await this.stateManager.GetOrAddAsync <IReliableDictionary <string, string> >(Constants.ClusterReliableDictionaryName); try { using (var tx = this.stateManager.CreateTransaction()) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Start transaction inside GetConfigUpgradeErrorDetailsAsync."); var data = await clusterStateTable.TryGetValueAsync(tx, key, Constants.DefaultDictionaryTimeout, cancellationToken).ConfigureAwait(false); if (data.HasValue) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Found persisted configUpgradeErrorDetails. Deserializing it."); configUpgradeErrorDetails = JsonConvert.DeserializeObject <ConfigUpgradeErrorDetail>( data.Value, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize, NullValueHandling = NullValueHandling.Ignore, TypeNameHandling = TypeNameHandling.Objects }); } } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Exit transaction inside GetConfigUpgradeErrorDetailsAsync."); } catch (Exception e) { UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "GetConfigUpgradeErrorDetailsAsync: {0}", e.ToString()); throw; } return(configUpgradeErrorDetails); }