internal static void UpdateStandAloneClusterAutoWrpUpgrade(StandAloneCluster existingCluster, string msiCodeVersion) { var adminConfigVersion = new StandaloneAdminConfig(null, false); adminConfigVersion.Version.MsiVersion = msiCodeVersion; existingCluster.TargetWrpConfig = adminConfigVersion; }
internal static void UpdateStandAloneCluster(string targetJsonFilePath, StandAloneCluster existingCluster, bool isUserSet = false) { StandAloneInstallerJsonModelBase targetJsonConfig = StandAloneInstallerJsonModelBase.GetJsonConfigFromFile(Path.Combine(Utility.TestDirectory, targetJsonFilePath)); StandaloneSettingsValidator validator = new StandaloneSettingsValidator(targetJsonConfig); existingCluster.TargetCsmConfig = validator.ClusterProperties; existingCluster.Topology = validator.Topology; if (!string.IsNullOrEmpty(validator.ClusterProperties.CodeVersion)) { var adminConfigVersion = new StandaloneAdminConfig(null, isUserSet); adminConfigVersion.Version.MsiVersion = validator.ClusterProperties.CodeVersion; existingCluster.TargetWrpConfig = adminConfigVersion; } }
internal static StandAloneCluster ConstructClusterFromJson(StandAloneInstallerJsonModelBase jsonModel, FabricNativeConfigStore configStore) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating userconfig, cluster topology, adminconfig."); var userConfig = jsonModel.GetUserConfig(); var clusterTopology = jsonModel.GetClusterTopology(); var adminConfig = new StandaloneAdminConfig(); var logger = new StandAloneTraceLogger("StandAloneDeploymentManager"); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating new StandAlone cluster resource."); var clusterId = configStore.ReadUnencryptedString(Constants.SectionName, Constants.ClusterIdParameterName); var clusterResource = new StandAloneCluster(adminConfig, userConfig, clusterTopology, clusterId, logger); return(clusterResource); }
internal static StandAloneCluster PopulateStandAloneClusterWithBaselineJson(string jsonFilePath) { StandAloneInstallerJsonModelBase jsonConfig = StandAloneInstallerJsonModelBase.GetJsonConfigFromFile(Path.Combine(Utility.TestDirectory, jsonFilePath)); var userConfig = jsonConfig.GetUserConfig(); var clusterTopology = jsonConfig.GetClusterTopology(); var adminConfig = new StandaloneAdminConfig(); var logger = new StandAloneTraceLogger("StandAloneDeploymentManager"); string customizedClusterId = jsonConfig.GetClusterRegistrationId(); return(new StandAloneCluster( adminConfig, userConfig, clusterTopology, customizedClusterId ?? "acf4dc93-9b64-4504-8b6f-0b7fd052e096", logger)); }
protected override async Task RunAsync(CancellationToken cancellationToken) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Enter RunAsync"); try { var configStore = FabricNativeConfigStore.FabricGetConfigStore(); StandAloneFabricSettingsActivator.InitializeConfigStore(configStore); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "After InitializeAsync"); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Getting cluster resource from store manager."); StandAloneCluster cluster = await this.storeManager.GetClusterResourceAsync(Constants.ClusterReliableDictionaryKey, cancellationToken).ConfigureAwait(false); bool isInDatalossState = await DatalossHelper.IsInDatalossStateAsync(cancellationToken).ConfigureAwait(false); if (!isInDatalossState) { bool isBaselineUpgrade = false; if (cluster == null) { // Cluster resource does not exist, e.g. first time baseline upgrade. UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Cluster resource does not exist in store manager. Initiating new clsuter resource."); cluster = FabricUpgradeOrchestrationService.InitClusterResource(configStore); ReleaseAssert.AssertIf(cluster == null, "Cluster Resource cannot be initialized."); isBaselineUpgrade = true; await this.CompleteAndPersistBaselineStateAsync(cluster, cancellationToken).ConfigureAwait(false); } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Setting a valid cancellation token for UpgradeOrchestrationMessageProcessor"); this.messageProcessor.CancellationToken = cancellationToken; /* In version 5.7, we added Iron as a new entry to ReliabilityLevel enum. This entry was added as ReliabilityLevel = 1 and hence, it moved all the existing levels one level down. * For clusters created in <=5.6, when upgraded to 5.7+ the ReliabilityLevel field would be interpreted differently. The below code fixes this issue by reading the * UOS state and comparing it against the actual cluster state. If there is a mismatch it sets the UOS to the correct ReliabilityLevel. */ if (!isBaselineUpgrade && cluster.Current != null && cluster.Current.CSMConfig != null) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Current ReliabilityLevel set in UOS state {0}", cluster.Current.CSMConfig.ReliabilityLevel); var actualReliabilityLevelForCluster = await this.GetActualReliabilityLevelForCluster(cancellationToken).ConfigureAwait(false); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Actual ReliabilityLevel set for the cluster {0}", actualReliabilityLevelForCluster); if (actualReliabilityLevelForCluster != cluster.Current.CSMConfig.ReliabilityLevel) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "UOS ReliabilityLevel is inconsistent with actual reliability level for the cluster.. Setting UOS state to {0}", actualReliabilityLevelForCluster); cluster.Current.CSMConfig.ReliabilityLevel = actualReliabilityLevelForCluster; await this.storeManager.PersistClusterResourceAsync(Constants.ClusterReliableDictionaryKey, cluster, cancellationToken).ConfigureAwait(false); cluster = await this.storeManager.GetClusterResourceAsync(Constants.ClusterReliableDictionaryKey, cancellationToken).ConfigureAwait(false); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "UOS ReliabilityLevel set to {0}", cluster.Current.CSMConfig.ReliabilityLevel); } } /* This is a workaround till actual admin config upgrades are implemented. In 5.7 we changed some properties in ClusterSettings * but those will not take effect for clusters created with version < 5.7 since no upgrade reads those settings. * This workaround initiates a WRP config upgrade in the form of SimpleClusterUpgradeState if the settings found are old (after the code upgrade completes to this version). */ string isAdminConfigUpgradeAttempted = await this.storeManager.GetStorageObjectAsync(Constants.AdminConfigUpgradeAttemptedDictionaryKey, cancellationToken).ConfigureAwait(false); if (!isBaselineUpgrade && string.IsNullOrEmpty(isAdminConfigUpgradeAttempted) && this.IsFirewallRuleDisabled()) { UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Old admin configuration settings detected.. Will initiate admin config upgrade after code upgrade completes.."); bool isCurrentCodeUpgradeCompleted = false; while (!isCurrentCodeUpgradeCompleted) { isCurrentCodeUpgradeCompleted = await this.CheckCodeUpgradeCompletedAsync(cancellationToken).ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken).ConfigureAwait(false); } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Setting targetWRPConfig to initiate admin config upgrade."); var adminConfig = new StandaloneAdminConfig(); adminConfig.Version.ClusterSettingsVersion = "2.1"; cluster.TargetWrpConfig = adminConfig; await this.storeManager.SetStorageObjectAsync(Constants.AdminConfigUpgradeAttemptedDictionaryKey, "true", cancellationToken).ConfigureAwait(false); } if (!isBaselineUpgrade) { // If the cluster manifest versions don't match, send a health warning for users to know. Task manifestCheck = this.SetupClusterManifestVersionCheck(cancellationToken, cluster.Current.ExternalState.ClusterManifest.Version); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Invoking Orchestrator.StartUpgradeAsync"); Task t = this.Orchestrator.StartUpgradeAsync(cluster, cancellationToken, new ConfigurationUpgradeDescription()); } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Done with Orchestrator.StartUpgradeAsync"); } var goalStateProvisioner = new StandaloneGoalStateProvisioner(this.storeManager, this.Orchestrator, cancellationToken); Task goalStatePollTask = (goalStateProvisioner.IsAutoupgradeEnabled() || goalStateProvisioner.IsAutoupgradeInstallEnabled()) ? goalStateProvisioner.SetUpGoalStatePoll(cancellationToken, this.IsSkipInitialGoalStateCheck()) : Task.Run( () => { goalStateProvisioner.EmitGoalStateReachableHealth(this.fabricClient, true /*success*/); goalStateProvisioner.EmitClusterVersionSupportedHealth(this.fabricClient, true /*success*/); }, cancellationToken); await Task.Delay(Timeout.Infinite, cancellationToken).ConfigureAwait(false); } catch (FabricNotPrimaryException ex) { UpgradeOrchestrationTrace.TraceSource.WriteError(TraceType, ex.ToString()); } catch (FabricObjectClosedException ocex) { UpgradeOrchestrationTrace.TraceSource.WriteError(TraceType, ocex.ToString()); } UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Exit RunAsync"); }