Example #1
0
 public ClusterState(IUserConfig csmConfig, IAdminConfig wrpConfig, ClusterNodeConfig nodeConfig, ClusterExternalState externalState)
 {
     this.CSMConfig     = csmConfig;
     this.WRPConfig     = wrpConfig;
     this.NodeConfig    = nodeConfig;
     this.ExternalState = externalState;
 }
 protected GatekeepingClusterUpgradeState(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
 }
Example #3
0
 protected ScaleDownClusterUpgradeStateBase(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     Dictionary <string, int> nodeDiffList,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, nodeDiffList, traceLogger)
 {
 }
Example #4
0
 protected ScaleClusterUpgradeBase(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     Dictionary <string, int> nodeDiffCountList,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
     this.NodeDiffCountList = nodeDiffCountList;
 }
 protected SeedNodeUpgradeStateBase(
     List <string> disabledNodes,
     List <string> removedNodes,
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
     this.disabledNodes = disabledNodes ?? new List <string>();
     this.removedNodes  = removedNodes ?? new List <string>();
 }
 protected CertificateClusterUpgradeStateBase(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger,
     HashSet <string> certsAdded,
     HashSet <string> certsRemoved)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
     this.certificatesAdded   = certsAdded;
     this.certificatesRemoved = certsRemoved;
 }
        protected ClusterUpgradeStateBase(
            IUserConfig targetCsmConfig,
            IAdminConfig targetWrpConfig,
            ClusterNodeConfig targetNodeConfig,
            ICluster clusterResource,
            ITraceLogger traceLogger)
        {
            targetCsmConfig.MustNotBeNull("csmConfig");
            targetWrpConfig.MustNotBeNull("wrpConfig");
            targetNodeConfig.MustNotBeNull("nodeConfig");
            clusterResource.MustNotBeNull("clusterResource");

            this.TargetCsmConfig  = targetCsmConfig;
            this.TargetWrpConfig  = targetWrpConfig;
            this.TargetNodeConfig = targetNodeConfig;
            this.ClusterResource  = clusterResource;
            this.TraceLogger      = traceLogger;
        }
Example #8
0
        public bool TryCreateSeedNodeUpgradeState(
            IUserConfig csmConfig,
            IAdminConfig wrpConfig,
            ClusterNodeConfig nodeConfig,
            List <string> disabledNodes,
            List <string> removedNodes,
            out MultiphaseClusterUpgradeState seedNodeUpgradeState)
        {
            seedNodeUpgradeState = this.upgradeStateActivator.CreateSeedNodeUpgradeStateBase(
                disabledNodes,
                removedNodes,
                csmConfig,
                wrpConfig,
                nodeConfig,
                this.clusterResource,
                this.traceLogger);

            seedNodeUpgradeState.ValidateSettingChanges();
            return(seedNodeUpgradeState.StartProcessing());
        }
 protected ClusterManifestBuilder(
     IClusterTopology topology,
     SeedNodeSelector seedNodeSelector,
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     IManifestVersionGenerator versionGenerator,
     IFabricSettingsActivator fabricSettingsActivator,
     ClusterManifestGeneratorSettings clusterManifestGeneratorSettings,
     ITraceLogger traceLogger)
 {
     this.Topology                         = topology;
     this.SeedNodeSelector                 = seedNodeSelector;
     this.TargetCsmConfig                  = targetCsmConfig;
     this.TargetWrpConfig                  = targetWrpConfig;
     this.TargetNodeConfig                 = targetNodeConfig;
     this.VersionGenerator                 = versionGenerator;
     this.FabricSettingsActivator          = fabricSettingsActivator;
     this.ClusterManifestGeneratorSettings = clusterManifestGeneratorSettings;
     this.TraceLogger                      = traceLogger;
 }
Example #10
0
        private bool TryProcessUpgrade()
        {
            bool updated = false;

            while (this.clusterResource.Pending == null)
            {
                IUserConfig       csmConfig  = null;
                IAdminConfig      wrpConfig  = null;
                ClusterNodeConfig nodeConfig = null;
                if (this.clusterResource.TargetCsmConfig != null &&
                    !this.clusterResource.TargetCsmConfigUpgradeFailed)
                {
                    csmConfig = this.clusterResource.TargetCsmConfig;
                    if (this.clusterResource.TargetWrpConfig != null && this.clusterResource.TargetWrpConfig.IsUserSet)
                    {
                        // If the current target wrp config is set by user
                        // then the set it as part of the pending upgrade
                        wrpConfig = this.clusterResource.TargetWrpConfig;
                    }

                    if (this.clusterResource.TargetNodeConfig != null && this.clusterResource.TargetNodeConfig.IsUserSet)
                    {
                        // If the current target node config is set by user
                        // then set it as part of the pending upgrade
                        nodeConfig = this.clusterResource.TargetNodeConfig;
                    }
                }
                else
                {
                    csmConfig = this.clusterResource.Current.CSMConfig;
                }

                if (wrpConfig == null)
                {
                    if (csmConfig == this.clusterResource.Current.CSMConfig &&
                        this.clusterResource.TargetWrpConfig != null &&
                        !this.clusterResource.TargetWrpConfigUpgradeFailed)
                    {
                        wrpConfig = this.clusterResource.TargetWrpConfig;
                    }
                    else
                    {
                        wrpConfig = this.clusterResource.Current.WRPConfig;
                    }
                }

                if (nodeConfig == null)
                {
                    if (csmConfig == this.clusterResource.Current.CSMConfig &&
                        wrpConfig == this.clusterResource.Current.WRPConfig &&
                        !this.clusterResource.TargetCsmConfigUpgradeFailed &&
                        this.clusterResource.TargetNodeConfig != null)
                    {
                        nodeConfig = this.clusterResource.TargetNodeConfig;
                    }
                    else
                    {
                        nodeConfig = this.clusterResource.Current.NodeConfig;
                    }
                }

                if (csmConfig == this.clusterResource.Current.CSMConfig &&
                    wrpConfig == this.clusterResource.Current.WRPConfig &&
                    nodeConfig == this.clusterResource.Current.NodeConfig)
                {
                    // No new target selected
                    this.traceLogger.WriteInfo(
                        TraceType,
                        "TryProcessUpgrade: No new target selected. CsmConfig changed: {0}. WrpConfig changed: {1}. NodeConfig changed: {2}, CsmUpgradeFailed: {3}. WrpUpgradeFailed: {4}",
                        csmConfig != this.clusterResource.TargetCsmConfig,
                        wrpConfig != this.clusterResource.TargetWrpConfig,
                        nodeConfig != this.clusterResource.TargetNodeConfig,
                        this.clusterResource.TargetCsmConfigUpgradeFailed,
                        this.clusterResource.TargetWrpConfigUpgradeFailed);
                    return(updated);
                }

                ClusterUpgradeStateBase pendingUpgrade;
                if (!this.UpgradeFactory.TryCreateUpgradeState(csmConfig, wrpConfig, nodeConfig, out pendingUpgrade))
                {
                    this.traceLogger.WriteInfo(TraceType, "TryProcessUpgrade: Fail to create upgrade state");
                    return(updated);
                }

                updated = true;

                var clusterState = pendingUpgrade.ClusterUpgradeStarted();
                if (clusterState != null)
                {
                    this.clusterResource.Current = clusterState;
                    this.clusterResource.Pending = null;
                }
                else
                {
                    this.clusterResource.Pending = pendingUpgrade;
                }
            }

            this.traceLogger.WriteInfo(TraceType, "TryProcessUpgrade: Succeed to create upgrade state: {0}", this.clusterResource.Pending.GetType().ToString());
            return(updated);
        }
Example #11
0
        public bool TryCreateUpgradeState(
            IUserConfig csmConfig,
            IAdminConfig wrpConfig,
            ClusterNodeConfig nodeConfig,
            out ClusterUpgradeStateBase clusterUpgradeState)
        {
            csmConfig.MustNotBeNull("csmConfig");
            wrpConfig.MustNotBeNull("wrpConfig");
            nodeConfig.MustNotBeNull("nodeConfig");

            bool hasReliabilityScaledUp = false;

            clusterUpgradeState = null;

            if (this.clusterResource.Current == null)
            {
                clusterUpgradeState = this.upgradeStateActivator.CreateBaselineUpgradeState(
                    csmConfig,
                    wrpConfig,
                    nodeConfig,
                    this.clusterResource,
                    this.traceLogger);
            }
            else
            {
                HashSet <string> certsAdded, certsRemoved;
                bool             hasCertChanged = HasCertficateChanged(
                    csmConfig,
                    this.clusterResource.Current.CSMConfig,
                    out certsAdded,
                    out certsRemoved);

                hasReliabilityScaledUp = csmConfig.ReliabilityLevel > this.clusterResource.Current.CSMConfig.ReliabilityLevel;
                var hasReliabilityScaledDown = csmConfig.ReliabilityLevel < this.clusterResource.Current.CSMConfig.ReliabilityLevel;

                bool hasNodeStatusChanged = nodeConfig.Version != this.clusterResource.Current.NodeConfig.Version;

                if (hasCertChanged && (hasReliabilityScaledUp || hasReliabilityScaledDown))
                {
                    throw new ClusterManagementException(ClusterManagementErrorCode.CertificateAndScaleUpgradeTogetherNotAllowed);
                }

                if (hasCertChanged && hasNodeStatusChanged)
                {
                    throw new ClusterManagementException(ClusterManagementErrorCode.CertificateAndScaleUpgradeTogetherNotAllowed);
                }

                if (hasNodeStatusChanged && this.clusterResource.NodeTypeNodeStatusList == null)
                {
                    throw new ClusterManagementException(ClusterManagementErrorCode.ScaleUpAndScaleDownUpgradeNotAllowedForOlderClusters);
                }

                if (hasCertChanged)
                {
                    clusterUpgradeState = this.upgradeStateActivator.CreateCertificateClusterUpgradeState(
                        csmConfig,
                        wrpConfig,
                        nodeConfig,
                        this.clusterResource,
                        this.traceLogger,
                        certsAdded,
                        certsRemoved);
                }
                else if (hasReliabilityScaledDown || hasReliabilityScaledUp)
                {
                    clusterUpgradeState = this.upgradeStateActivator.CreateAutoScaleClusterUpgradeStateBase(
                        true /*initiatedByCsmRequest*/,
                        csmConfig,
                        wrpConfig,
                        nodeConfig,
                        this.clusterResource,
                        this.traceLogger);
                }
                else if (hasNodeStatusChanged)
                {
                    clusterUpgradeState = this.upgradeStateActivator.CreateAutoScaleClusterUpgradeStateBase(
                        false /*initiatedByCsmRequest*/,
                        csmConfig,
                        wrpConfig,
                        nodeConfig,
                        this.clusterResource,
                        this.traceLogger);
                }
                else
                {
                    clusterUpgradeState = this.upgradeStateActivator.CreateSimpleUpgradeState(
                        csmConfig,
                        wrpConfig,
                        nodeConfig,
                        this.clusterResource,
                        this.traceLogger);
                }
            }

            clusterUpgradeState.ValidateSettingChanges();
            bool processingSuccess = clusterUpgradeState.StartProcessing();

            if (!processingSuccess && hasReliabilityScaledUp)
            {
                //// If scaleup auto upgrade did not go through (only case now is enough nodes being available),
                //// then accept the request and complete the upgrade to ARM with success

                this.traceLogger.WriteInfo(TraceType, "TryCreateUpgradeState: StartProcessing returns false, so create SimpleUpgrade");
                clusterUpgradeState = this.upgradeStateActivator.CreateSimpleUpgradeState(
                    csmConfig,
                    wrpConfig,
                    nodeConfig,
                    this.clusterResource,
                    this.traceLogger);

                clusterUpgradeState.ValidateSettingChanges();
                return(clusterUpgradeState.StartProcessing());
            }

            this.traceLogger.WriteInfo(TraceType, "TryCreateUpgradeState: {0} is created.", clusterUpgradeState.GetType().Name);
            return(processingSuccess);
        }