Example #1
0
 private static string GenerateRepairTaskId(ImpactActionEnum impactAction, Guid jobId, uint?jobUD, int jobDocIncarnation)
 {
     return(Constants.DefaultRepairTaskIdFormat.ToString(
                impactAction,
                jobId,
                jobUD.HasValue ? jobUD.ToString() : "-",
                jobDocIncarnation));
 }
Example #2
0
            private void InitializeCount(ImpactActionEnum jobType, int?maxCount = null)
            {
                JobCount count = new JobCount()
                {
                    ActiveCount = 0,
                    MaxCount    = maxCount.HasValue ? maxCount.Value : GetMaxCountFromConfig(jobType),
                };

                map.Add(jobType, count);
            }
Example #3
0
        /// <summary>
        /// Translates the impact details to an RM node impact level.
        /// </summary>
        /// <param name="impactDetail">The impact details to be translated.</param>
        /// <returns>The node impact level to be sent to the RM.</returns>
        public NodeImpactLevel TranslateImpactDetailToNodeImpactLevel(ImpactActionEnum jobType, AffectedResourceImpact impactDetail)
        {
            impactDetail.Validate("impactDetail");

            ImpactCategory category;

            if (IsInstanceRemoval(jobType, impactDetail))
            {
                // Handle instance removal as a special case
                category = ImpactCategory.Decommission;
                tracer.WriteInfo("Overall impact set to {0} due to instance removal", category);
            }
            else
            {
                category = TranslateImpactDetailToCategory(impactDetail);
            }

            return(TranslateImpactCategoryToNodeImpactLevel(category));
        }
Example #4
0
        public static ITenantJob CreateNewTenantJob(
            ImpactActionEnum impactAction = ImpactActionEnum.TenantUpdate,
            uint ud = 0,
            List <string> roleInstances = null,
            string context = null)
        {
            var impactedResources = new AffectedResourceImpact
            {
                ListOfImpactTypes = new List <ImpactTypeEnum> {
                    ImpactTypeEnum.Reboot
                }
            };

            if (roleInstances == null)
            {
                roleInstances = new List <string> {
                    "Role_IN_0", "Role_IN_1"
                };
            }

            var tenantJob = new MockTenantJob(Guid.NewGuid())
            {
                JobStep      = CreateNewJobStepInfo(ud, roleInstances),
                ImpactDetail = new MockImpactInfo {
                    ImpactAction = impactAction, ImpactedResources = impactedResources
                },
                JobStatus = JobStatusEnum.Executing,
            };

            if (context != null)
            {
                // the explicit null check is to signify that the context should not be added for jobs like platformupdate etc.
                tenantJob.ContextStringGivenByTenant = context;
            }

            tenantJob.RoleInstancesToBeImpacted =
                tenantJob.JobStep.CurrentlyImpactedRoleInstances.Select(e => e.RoleInstanceName).ToList();

            return(tenantJob);
        }
Example #5
0
        private bool IsInstanceRemoval(ImpactActionEnum jobType, AffectedResourceImpact impactDetail)
        {
            bool isInstanceRemovalImpact =
                jobType == ImpactActionEnum.TenantUpdate &&
                CoordinatorHelper.AllImpactsEqual(impactDetail, Impact.Wipe);

            bool isInstanceRemovalLegacy = false;

            if (impactDetail.ListOfImpactTypes != null)
            {
                isInstanceRemovalLegacy = impactDetail.ListOfImpactTypes.Contains(ImpactTypeEnum.InstanceRemoval);
            }

            if (isInstanceRemovalImpact != isInstanceRemovalLegacy)
            {
                tracer.WriteWarning(
                    "Mismatch between IsInstanceRemoval result from resource impacts ({0}) and ImpactTypeEnum ({1}); using {0}",
                    isInstanceRemovalImpact,
                    isInstanceRemovalLegacy);
            }

            return(isInstanceRemovalImpact);
        }
Example #6
0
 private static string GenerateRepairAction(ImpactActionEnum impactAction)
 {
     // e.g. System.Azure.Job.PlatformUpdate
     return(Constants.RepairActionFormat.ToString("Job." + impactAction));
 }
Example #7
0
 private int GetMaxCountFromConfig(ImpactActionEnum jobType)
 {
     return(configSection.ReadConfigValue(
                Constants.ConfigKeys.MaxParallelJobCountKeyPrefix + jobType,
                DefaultMaxParallelJobCountPerImpactAction));
 }