Beispiel #1
0
 public CreateInPreparingAction(
     CoordinatorEnvironment environment,
     IRepairManager repairManager,
     ITenantJob tenantJob,
     bool surpriseJob,
     RepairTaskPrepareArgs args)
     : base(environment, ActionType.Prepare)
 {
     this.repairManager = repairManager.Validate("repairManager");
     this.tenantJob     = tenantJob.Validate("tenantJob");
     this.surpriseJob   = surpriseJob;
     this.args          = args.Validate("args");
 }
Beispiel #2
0
        public static RepairTaskPrepareArgs FromTenantJob(
            ITenantJob tenantJob,
            int jobDocIncarnation,
            CoordinatorEnvironment environment,
            bool isVendorRepair,
            bool restoringHealthCheckOnly,
            string description = null)
        {
            tenantJob.Validate("tenantJob");
            environment.Validate("environment");

            var jobId = tenantJob.Id;
            var ud    = tenantJob.GetJobUD();

            string jobStepId = tenantJob.GetJobStepId();

            if (jobStepId == null)
            {
                environment.DefaultTraceType.WriteWarning(
                    "RepairTaskPrepareArgs.FromTenantJob: not continuing since job step ID is null in job: {0}",
                    tenantJob.ToJson());

                return(null);
            }

            // use the role instance names from the JobStep. Don't use tenantJob.RoleInstancesToBeImpacted
            // since that lists all the role instances that will be impacted.
            // E.g. in a tenant update job, where multiple UDs are walked, if there are 8 role instances,
            // tenantJob.RoleInstancesToBeImpacted will list all 8, whereas
            // tenantJob.JobStep.CurrentlyImpactedRoleInstances will list only those in the current UD of the jobstep
            var nodeNames = new List <string>();

            if (tenantJob.JobStep.CurrentlyImpactedRoleInstances != null)
            {
                nodeNames.AddRange(tenantJob.JobStep.CurrentlyImpactedRoleInstances.Select(
                                       e => e.RoleInstanceName.TranslateRoleInstanceToNodeName()));
            }

            var executorData = new RepairTaskExecutorData
            {
                JobId  = jobId.ToString(),
                UD     = ud,
                StepId = jobStepId,
            };

            if (isVendorRepair)
            {
                executorData.Flags = RepairTaskExecutorData.VendorRepairFlag;
            }

            string repairTaskId = GenerateRepairTaskId(
                tenantJob.GetImpactAction(),
                jobId,
                ud,
                jobDocIncarnation);

            string repairAction = GenerateRepairAction(tenantJob.GetImpactAction());

            var args = new RepairTaskPrepareArgs()
            {
                TaskId       = repairTaskId,
                Description  = description,
                Action       = repairAction,
                ExecutorData = executorData,
                Target       = new NodeRepairTargetDescription(nodeNames),
            };

            if (restoringHealthCheckOnly)
            {
                args.Impact = new NodeRepairImpactDescription();
                args.PerformPreparingHealthCheck = false;
                args.PerformRestoringHealthCheck = true;
            }
            else
            {
                args.Impact = GetImpactFromDetails(tenantJob, environment);
                args.PerformPreparingHealthCheck = tenantJob.DoesJobRequirePreparingHealthCheck(environment.Config);
                args.PerformRestoringHealthCheck = tenantJob.DoesJobRequireRestoringHealthCheck(environment.Config);
            }

            if (tenantJob.IsTenantUpdateJobType() && nodeNames.Count == 0)
            {
                // Never perform health checks on TenantUpdate job steps that have zero role
                // instances listed. These occur at the end of each UD walk when the tenant
                // setting Tenant.PolicyAgent.TenantUpdateUdCleanupApprovalRequired == true.
                args.PerformPreparingHealthCheck = false;
                args.PerformRestoringHealthCheck = false;
            }

            return(args);
        }
Beispiel #3
0
 public IAction NewCreateInPreparingAction(ITenantJob tenantJob, RepairTaskPrepareArgs args, bool surpriseJob = false)
 {
     return(new CreateInPreparingAction(environment, repairManager, tenantJob, surpriseJob, args));
 }