Ejemplo n.º 1
0
        public override bool StartProcessing()
        {
            // Get list of already disabled nodes
            List <string> disabledNodes = new List <string>();

            foreach (var nodesPerNodeType in this.ClusterResource.NodeTypeNodeStatusList.Values)
            {
                var nodesDisabledInNodeType = nodesPerNodeType.Values.Where(nodeStatus => nodeStatus.NodeState == NodeState.Disabled)
                                              .Select(nodeStatus => nodeStatus.NodeName);
                disabledNodes.AddRange(nodesDisabledInNodeType);
            }

            MultiphaseClusterUpgradeState seedNodeUpgradeState;

            if (!this.ClusterResource.UpgradeFactory.TryCreateSeedNodeUpgradeState(
                    this.TargetCsmConfig,
                    this.TargetWrpConfig,
                    this.TargetNodeConfig,
                    disabledNodes,
                    null /*removedNodes is specified only for AutoScale*/,
                    out seedNodeUpgradeState))
            {
                ReleaseAssert.Failfast("We should not have a case where enough nodes are not available during scale down.");
            }
            else
            {
                this.SeedNodeUpgradeState = seedNodeUpgradeState;
                this.SeedNodeUpgradeState.ClusterUpgradeStarted();

                this.ExternalState         = this.SeedNodeUpgradeState.ExternalState;
                this.PreviousExternalState = this.SeedNodeUpgradeState.PreviousExternalState;
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool StartProcessing()
        {
            this.TraceLogger.WriteInfo(
                TraceType,
                "Start@StartProcessing: TargetNodeVersion: {0}, CurrentNodeVersion: {1}",
                this.TargetNodeConfig.Version,
                this.ClusterResource.Current.NodeConfig.Version);

            var disabledNodes = this.TargetNodeConfig.NodesStatus
                                .Where(nodeStatus => nodeStatus.NodeDeactivationIntent == WrpNodeDeactivationIntent.RemoveNode)
                                .Select(nodeStatus => nodeStatus.NodeName);

            var removedNodes = this.TargetNodeConfig.NodesStatus
                               .Where(nodeStatus => nodeStatus.NodeState == NodeState.Removed)
                               .Select(nodeStatus => nodeStatus.NodeName);

            MultiphaseClusterUpgradeState seedNodeUpgradeState;

            if (!this.ClusterResource.UpgradeFactory.TryCreateSeedNodeUpgradeState(
                    this.TargetCsmConfig,
                    this.TargetWrpConfig,
                    this.TargetNodeConfig,
                    new List <string>(disabledNodes),
                    new List <string>(removedNodes),
                    out seedNodeUpgradeState))
            {
                return(false);
            }
            else
            {
                this.SeedNodeUpgradeState = seedNodeUpgradeState;
                this.Validate();
                this.SeedNodeUpgradeState.ClusterUpgradeStarted();

                if (this.SeedNodeUpgradeState.ExternalState.Equals(this.SeedNodeUpgradeState.PreviousExternalState))
                {
                    // There is no seed node upgrade to do.
                    // Assume that there is no system service scale required either since they are currently tied together.
                    // Change logic if we have a condition where system services scale is required even when seed node change
                    // is not required.
                    this.skipSystemServicesReplicaScale = true;
                }

                this.ExternalState         = this.SeedNodeUpgradeState.ExternalState;
                this.PreviousExternalState = this.SeedNodeUpgradeState.PreviousExternalState;
            }

            return(true);
        }
Ejemplo n.º 3
0
        public override ClusterState ClusterUpgradeCompleted()
        {
            if (this.SeedNodeUpgradeState != null)
            {
                var clusterState = this.SeedNodeUpgradeState.ClusterUpgradeCompleted();
                if (clusterState == null)
                {
                    // SeedNode upgrade has not completed yet
                    this.ExternalState         = this.SeedNodeUpgradeState.ExternalState;
                    this.PreviousExternalState = this.SeedNodeUpgradeState.PreviousExternalState;

                    return(null);
                }
                else
                {
                    // SeedNode upgrade has completed
                    this.SeedNodeUpgradeState = null;
                }
            }

            // Initiate system services replica set size adjustment
            // once SeedNode upgrade is done
            this.SetTargetSystemServicesReplicaSetSize();

            if (this.VerifyTargetSystemServicesReplicaSetSize())
            {
                // Disable/Enable nodes once system services replica set size
                // is adjusted
                if (!this.UpdateClusterResourceNodesStatus())
                {
                    this.TraceLogger.WriteInfo(
                        TraceType,
                        "Scaledown cluster upgrade completed. TargetCsmVersion: {0}, TargetWrpVersion: {1}",
                        this.TargetCsmConfig.Version,
                        this.TargetWrpConfig.Version);

                    this.ClusterResource.ClusterState = ClusterProvisioningState.Ready;

                    this.ResetTargetConfigs();

                    this.OnScaleDownClusterUpgradeCompleted();

                    return(new ClusterState(this.TargetCsmConfig, this.TargetWrpConfig, this.TargetNodeConfig, this.ExternalState));
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override ClusterState ClusterUpgradeCompleted()
        {
            if (this.SeedNodeUpgradeState != null)
            {
                var clusterState = this.SeedNodeUpgradeState.ClusterUpgradeCompleted();
                if (clusterState == null)
                {
                    // SeedNode upgrade has not completed yet
                    this.ExternalState         = this.SeedNodeUpgradeState.ExternalState;
                    this.PreviousExternalState = this.SeedNodeUpgradeState.PreviousExternalState;

                    return(null);
                }
                else
                {
                    // SeedNode upgrade has completed
                    this.SeedNodeUpgradeState = null;
                }
            }

            if (!this.skipSystemServicesReplicaScale)
            {
                // Initiate system services replica set size adjustment
                // once SeedNode upgrade is done
                this.SetTargetSystemServicesReplicaSetSize();
            }

            if (this.skipSystemServicesReplicaScale || this.VerifyTargetSystemServicesReplicaSetSize())
            {
                this.TraceLogger.WriteInfo(
                    TraceType,
                    "Autoscale cluster upgrade completed. TargetCsmVersion: {0}, TargetWrpVersion: {1}, TargetNodeVersion",
                    this.TargetCsmConfig.Version,
                    this.TargetWrpConfig.Version,
                    this.TargetNodeConfig.Version);

                this.OnAutoScaleUpgradeCompleted();

                this.ResetTargetConfigs();

                return(new ClusterState(this.TargetCsmConfig, this.TargetWrpConfig, this.TargetNodeConfig, this.ExternalState));
            }

            return(null);
        }
Ejemplo n.º 5
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());
        }
        public override ClusterState ClusterUpgradeCompleted()
        {
            // Ensure that the Nodes are Disabled/Enabled
            if (this.SeedNodeUpgradeState == null && this.VerifyExpectedTopologyStateReached())
            {
                this.TraceLogger.WriteInfo(
                    TraceType,
                    "Expected node status reached. Initiating Seed Node upgrade.");

                List <string> disabledNodes = new List <string>();
                foreach (var nodesPerNodeType in this.ClusterResource.NodeTypeNodeStatusList.Values)
                {
                    var nodesDisabledInNodeType = nodesPerNodeType.Values.Where(nodeStatus => nodeStatus.NodeState == NodeState.Disabled)
                                                  .Select(nodeStatus => nodeStatus.NodeName);
                    disabledNodes.AddRange(nodesDisabledInNodeType);
                }

                // Disable/Enabled nodes completed. Initiate SeedNode upgrade if required
                MultiphaseClusterUpgradeState seedNodeUpgradeState;
                if (!this.ClusterResource.UpgradeFactory.TryCreateSeedNodeUpgradeState(
                        this.TargetCsmConfig,
                        this.TargetWrpConfig,
                        this.TargetNodeConfig,
                        disabledNodes,
                        null /*removedNodes is specified only for AutoScale*/,
                        out seedNodeUpgradeState))
                {
                    this.TraceLogger.WriteInfo(
                        TraceType,
                        "Enough nodes are not available for scaling up seed nodes.");

                    // enough nodes are not available for scaling up seed nodes
                    return(null);
                }
                else
                {
                    this.SeedNodeUpgradeState = seedNodeUpgradeState;
                    this.SeedNodeUpgradeState.ClusterUpgradeStarted();
                }
            }
            else if (this.SeedNodeUpgradeState != null)
            {
                var clusterState = this.SeedNodeUpgradeState.ClusterUpgradeCompleted();
                if (clusterState != null)
                {
                    // SeedNode upgrade is completed. Initiate adjustment of system services replica set size
                    this.SetTargetSystemServicesReplicaSetSize();
                }
            }

            if (this.VerifyTargetSystemServicesReplicaSetSize())
            {
                this.TraceLogger.WriteInfo(
                    TraceType,
                    "Scaleup cluster upgrade completed. TargetCsmVersion: {0}, TargetWrpVersion: {1}",
                    this.TargetCsmConfig.Version,
                    this.TargetWrpConfig.Version);

                this.ClusterResource.ClusterState = ClusterProvisioningState.Ready;

                this.ResetTargetConfigs();

                this.OnScaleUpClusterUpgradeCompleted();

                // return ClusterState to indicate that ScaleUpClusterUpgrade has completed
                return(new ClusterState(this.TargetCsmConfig, this.TargetWrpConfig, this.TargetNodeConfig, this.ExternalState));
            }

            if (this.SeedNodeUpgradeState != null)
            {
                // SeedNode upgrade is still going on
                this.ExternalState         = this.SeedNodeUpgradeState.ExternalState;
                this.PreviousExternalState = this.SeedNodeUpgradeState.PreviousExternalState;
            }

            return(null);
        }