Beispiel #1
0
        public JobBlockingActionPolicy(CoordinatorEnvironment environment, IJobBlockingPolicyManager jobBlockingPolicyManager)
        {
            environment.Validate("environment");

            this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
            this.traceType = environment.CreateTraceType("PolicyJobBlocking");
        }
Beispiel #2
0
        private static NodeRepairImpactDescription GetImpactFromDetails(ITenantJob tenantJob, CoordinatorEnvironment environment)
        {
            environment.Validate("environment");

            var translator = new ImpactTranslator(environment);
            var impact     = new NodeRepairImpactDescription();

            if (tenantJob.JobStep == null || tenantJob.JobStep.CurrentlyImpactedRoleInstances == null)
            {
                return(impact);
            }

            foreach (var roleInstance in tenantJob.JobStep.CurrentlyImpactedRoleInstances)
            {
                string nodeName = roleInstance.RoleInstanceName.TranslateRoleInstanceToNodeName();

                NodeImpactLevel impactLevel = translator.TranslateImpactDetailToNodeImpactLevel(
                    tenantJob.ImpactDetail.ImpactAction,
                    roleInstance.ExpectedImpact);

                if (impactLevel != NodeImpactLevel.None)
                {
                    var nodeImpact = new NodeImpact(nodeName, impactLevel);
                    impact.ImpactedNodes.Add(nodeImpact);
                }
            }

            return(impact);
        }
Beispiel #3
0
 public PolicyAgentServiceWrapper(CoordinatorEnvironment environment, IActivityLogger activityLogger, Uri zeroSdkUri = null, bool silentErrors = false)
 {
     this.traceType      = environment.Validate("environment").CreateTraceType("ZeroSdkClient");
     this.activityLogger = activityLogger.Validate("activityLogger");
     this.traceWriteConditionalWarning = silentErrors ? new WriteTraceDelegate(traceType.WriteInfo) : new WriteTraceDelegate(traceType.WriteWarning);
     this.zeroSdkUri = zeroSdkUri ?? GetMRZeroSdkUri(environment.Config);
 }
Beispiel #4
0
        public AzureParallelDisabledCoordinator(
            CoordinatorEnvironment environment,
            string tenantId,
            Func <Task <IPolicyAgentClient> > policyAgentClientAsyncFactory,
            IRepairManager repairManager,
            IHealthClient healthClient,
            IActivityLogger activityLogger,
            Guid partitionId,
            long replicaId)
        {
            this.environment = environment.Validate("environment");
            this.tenantId    = tenantId.Validate("tenantId");
            this.partitionId = partitionId;
            this.policyAgentClientAsyncFactory = policyAgentClientAsyncFactory.Validate("policyAgentClientAsyncFactory");

            this.traceType = environment.CreateTraceType("DisabledCoordinator");

            this.repairManager = repairManager.Validate("repairManager");
            this.healthClient  = healthClient.Validate("healthClient");

            this.configSection  = environment.Config;
            this.activityLogger = activityLogger.Validate("activityLogger");

            var assembly = this.GetType().GetTypeInfo().Assembly;

            assemblyFileVersion = FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
        }
Beispiel #5
0
        public ServiceFabricRepairManager(CoordinatorEnvironment environment, IActivityLogger activityLogger)
        {
            this.activityLogger = activityLogger.Validate("activityLogger");
            this.traceType      = environment.Validate("environment").CreateTraceType("RMClient");

            this.repairManager = this.fabricClient.RepairManager;
        }
Beispiel #6
0
 public DefaultActionPolicyFactory(
     CoordinatorEnvironment environment,
     IJobBlockingPolicyManager jobBlockingPolicyManager,
     IAllowActionMap allowActionMap)
 {
     this.environment = environment.Validate("environment");
     this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
     this.allowActionMap           = allowActionMap.Validate("allowActionMap");
 }
Beispiel #7
0
        public ServiceFabricRepairManagerFactory(CoordinatorEnvironment environment, IActivityLogger activityLogger)
        {
            this.activityLogger = activityLogger.Validate("activityLogger");
            this.fabricClient   = new FabricClient();
            this.environment    = environment.Validate("environment");

            this.retryPolicyFactory = new LinearRetryPolicyFactory(
                environment.DefaultTraceType,
                Constants.BackoffPeriodInMilliseconds,
                Constants.MaxRetryAttempts,
                ex => ex is TimeoutException);
        }
Beispiel #8
0
 public ActionFactory(
     CoordinatorEnvironment environment,
     IPolicyAgentClient policyAgentClient,
     IRepairManager repairManager,
     RepairActionProvider repairActionProvider)
 {
     this.environment          = environment.Validate("environment");
     this.policyAgentClient    = policyAgentClient.Validate("policyAgentClient");
     this.repairManager        = repairManager.Validate("repairManager");
     this.repairActionProvider = repairActionProvider.Validate("repairActionProvider");
     this.jobResponseMap       = new Dictionary <Guid, JobStepResponseEnum>();
 }
Beispiel #9
0
        public CoordinatorCommandProcessor(
            CoordinatorEnvironment environment,
            IPolicyAgentClient policyAgentClient,
            IJobBlockingPolicyManager jobBlockingPolicyManager,
            IAllowActionMap allowActionMap)
        {
            this.environment              = environment.Validate("environment");
            this.policyAgentClient        = policyAgentClient.Validate("policyAgentClient");
            this.jobBlockingPolicyManager = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
            this.allowActionMap           = allowActionMap.Validate("allowActionMap");

            this.traceType      = environment.CreateTraceType("CommandProcessor");
            this.commandHandler = new CommandHandler(this.traceType);

            RegisterCommandHandlers();
        }
        public AzureParallelInfrastructureCoordinator(
            CoordinatorEnvironment environment,
            string tenantId,
            IPolicyAgentClient policyAgentClient,
            IRepairManager repairManager,
            IHealthClient healthClient,
            ICoordinatorCommandProcessor coordinatorCommandProcessor,
            IJobBlockingPolicyManager jobBlockingPolicyManager,
            IActionPolicyFactory actionPolicyFactory,
            IActivityLogger activityLogger,
            Guid partitionId,
            long replicaId)
        {
            this.environment       = environment.Validate("environment");
            this.tenantId          = tenantId.Validate("tenantId");
            this.partitionId       = partitionId;
            this.policyAgentClient = policyAgentClient.Validate("policyAgentClient");

            this.traceType       = environment.CreateTraceType("Coordinator");
            this.actionTraceType = environment.CreateTraceType("Action");

            this.repairManager = repairManager.Validate("repairManager");
            this.healthClient  = healthClient.Validate("healthClient");

            this.configSection = environment.Config;
            this.coordinatorCommandProcessor = coordinatorCommandProcessor.Validate("coordinatorCommandProcessor");
            this.jobBlockingPolicyManager    = jobBlockingPolicyManager.Validate("jobBlockingPolicyManager");
            this.actionPolicies = actionPolicyFactory.Validate("actionPolicyFactory").Create();
            this.activityLogger = activityLogger.Validate("activityLogger");

            var assembly = this.GetType().GetTypeInfo().Assembly;

            assemblyFileVersion = FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;

            var healthWatchdogFactory = new RoleInstanceHealthWatchdogFactory(configSection, healthClient);

            roleInstanceHealthWatchdog = healthWatchdogFactory.Create(Constants.ConfigKeys.ConfigKeyPrefix);
        }
Beispiel #11
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 #12
0
 public ServiceFabricRepairManagerFactory(CoordinatorEnvironment environment, IActivityLogger activityLogger, string[] hostEndpoints)
 {
     this.activityLogger = activityLogger.Validate("activityLogger");
     this.fabricClient   = new FabricClient(new FabricClientSettings(), hostEndpoints);
     this.environment    = environment.Validate("environment");
 }
 public PrePostExecuteActionPolicy(CoordinatorEnvironment environment)
 {
     this.traceType = environment.Validate("environment").CreateTraceType("PolicyPrePostExecute");
     this.config    = environment.Config;
 }
Beispiel #14
0
 public ImpactTranslator(CoordinatorEnvironment environment)
 {
     environment.Validate("environment");
     this.configSection = environment.Config;
     this.tracer        = environment.CreateTraceType("ImpactTranslator");
 }
Beispiel #15
0
 protected Action(CoordinatorEnvironment environment, ActionType actionType)
 {
     this.Environment = environment.Validate("environment");
     this.ActionType  = actionType;
 }
Beispiel #16
0
 public ExternalAllowActionPolicy(CoordinatorEnvironment environment, IAllowActionMap allowActionMap)
 {
     this.traceType      = environment.Validate("environment").CreateTraceType("PolicyExternalAllow");
     this.allowActionMap = allowActionMap.Validate("allowActionMap");
 }
 public PolicyAgentClient(CoordinatorEnvironment environment, IPolicyAgentServiceWrapper policyAgentService, IActivityLogger activityLogger)
 {
     this.traceType          = environment.Validate("environment").CreateTraceType("PolicyAgentClient");
     this.policyAgentService = policyAgentService.Validate("policyAgentService");
     this.activityLogger     = activityLogger.Validate("activityLogger");
 }
Beispiel #18
0
 public JobThrottlingActionPolicy(CoordinatorEnvironment environment)
 {
     environment.Validate("environment");
     this.configSection = environment.Config;
     this.traceType     = environment.CreateTraceType("PolicyJobThrottling");
 }