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;
        }
示例#2
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);
        }