diff --git a/pkg/controllers/automigration/controller.go b/pkg/controllers/automigration/controller.go index 75028b9c..2498d7a5 100644 --- a/pkg/controllers/automigration/controller.go +++ b/pkg/controllers/automigration/controller.go @@ -213,9 +213,9 @@ func (c *Controller) reconcile(qualifiedName common.QualifiedName) (status worke if unschedulableThreshold == nil { // Clean up the annotation if auto migration is disabled. keyedLogger.V(3).Info("Auto migration is disabled") - _, exists := annotations[common.AutoMigrationAnnotation] + _, exists := annotations[common.AutoMigrationInfoAnnotation] if exists { - delete(annotations, common.AutoMigrationAnnotation) + delete(annotations, common.AutoMigrationInfoAnnotation) needsUpdate = true } } else { @@ -228,25 +228,25 @@ func (c *Controller) reconcile(qualifiedName common.QualifiedName) (status worke } estimatedCapacity, result = c.estimateCapacity(ctx, clusterObjs, *unschedulableThreshold) - autoMigration := &framework.AutoMigrationInfo{EstimatedCapacity: estimatedCapacity} + autoMigrationInfo := &framework.AutoMigrationInfo{EstimatedCapacity: estimatedCapacity} // Compare with the existing autoMigration annotation - existingAutoMigration := &framework.AutoMigrationInfo{EstimatedCapacity: nil} - if existingAutoMigrationBytes, exists := annotations[common.AutoMigrationAnnotation]; exists { - err := json.Unmarshal([]byte(existingAutoMigrationBytes), existingAutoMigration) + existingAutoMigrationInfo := &framework.AutoMigrationInfo{EstimatedCapacity: nil} + if existingAutoMigrationInfoBytes, exists := annotations[common.AutoMigrationInfoAnnotation]; exists { + err := json.Unmarshal([]byte(existingAutoMigrationInfoBytes), existingAutoMigrationInfo) if err != nil { keyedLogger.Error(err, "Existing auto migration annotation is invalid, ignoring") // we treat invalid existing annotation as if it doesn't exist } } - if !equality.Semantic.DeepEqual(existingAutoMigration, autoMigration) { - autoMigrationBytes, err := json.Marshal(autoMigration) + if !equality.Semantic.DeepEqual(existingAutoMigrationInfo, autoMigrationInfo) { + autoMigrationInfoBytes, err := json.Marshal(autoMigrationInfo) if err != nil { keyedLogger.Error(err, "Failed to marshal auto migration") return worker.StatusAllOK } - annotations[common.AutoMigrationAnnotation] = string(autoMigrationBytes) + annotations[common.AutoMigrationInfoAnnotation] = string(autoMigrationInfoBytes) needsUpdate = true } } diff --git a/pkg/controllers/common/constants.go b/pkg/controllers/common/constants.go index 97145732..a3e6d522 100644 --- a/pkg/controllers/common/constants.go +++ b/pkg/controllers/common/constants.go @@ -124,8 +124,8 @@ const ( // When a pod remains unschedulable beyond this threshold, it becomes eligible for automatic migration. PodUnschedulableThresholdAnnotation = InternalPrefix + "pod-unschedulable-threshold" - // AutoMigrationAnnotation contains auto migration information. - AutoMigrationAnnotation = DefaultPrefix + "auto-migration" + // AutoMigrationInfoAnnotation contains auto migration information. + AutoMigrationInfoAnnotation = DefaultPrefix + "auto-migration-info" ) // The following consts are keys used to store information in the federated cluster secret diff --git a/pkg/controllers/scheduler/framework/types.go b/pkg/controllers/scheduler/framework/types.go index b814aa91..e032655a 100644 --- a/pkg/controllers/scheduler/framework/types.go +++ b/pkg/controllers/scheduler/framework/types.go @@ -46,7 +46,7 @@ type SchedulingUnit struct { // Describes the current scheduling state CurrentClusters map[string]*int64 - AutoMigration *AutoMigrationConfig + AutoMigration *AutoMigrationSpec // Controls the scheduling behavior SchedulingMode fedcorev1a1.SchedulingMode @@ -64,7 +64,7 @@ type SchedulingUnit struct { Weights map[string]int64 } -type AutoMigrationConfig struct { +type AutoMigrationSpec struct { Info *AutoMigrationInfo KeepUnschedulableReplicas bool } diff --git a/pkg/controllers/scheduler/schedulingtriggers.go b/pkg/controllers/scheduler/schedulingtriggers.go index 6fc72505..b4a13969 100644 --- a/pkg/controllers/scheduler/schedulingtriggers.go +++ b/pkg/controllers/scheduler/schedulingtriggers.go @@ -121,7 +121,7 @@ func (s *Scheduler) computeSchedulingTriggerHash( trigger.PolicyGeneration = policy.GetGeneration() if policy.GetSpec().AutoMigration != nil { // Only consider auto-migration annotation when auto-migration is enabled in the policy. - if value, exists := fedObject.GetAnnotations()[common.AutoMigrationAnnotation]; exists { + if value, exists := fedObject.GetAnnotations()[common.AutoMigrationInfoAnnotation]; exists { trigger.AutoMigrationInfo = &value } } diff --git a/pkg/controllers/scheduler/schedulingunit.go b/pkg/controllers/scheduler/schedulingunit.go index b55f04ac..7e156187 100644 --- a/pkg/controllers/scheduler/schedulingunit.go +++ b/pkg/controllers/scheduler/schedulingunit.go @@ -89,7 +89,7 @@ func (s *Scheduler) schedulingUnitForFedObject( if err != nil { return nil, err } - schedulingUnit.AutoMigration = &framework.AutoMigrationConfig{ + schedulingUnit.AutoMigration = &framework.AutoMigrationSpec{ Info: info, KeepUnschedulableReplicas: autoMigration.KeepUnschedulableReplicas, } @@ -235,16 +235,16 @@ func getSchedulingModeFromObject(object *unstructured.Unstructured) (fedcorev1a1 } func getAutoMigrationInfo(fedObject *unstructured.Unstructured) (*framework.AutoMigrationInfo, error) { - value, exists := fedObject.GetAnnotations()[common.AutoMigrationAnnotation] + value, exists := fedObject.GetAnnotations()[common.AutoMigrationInfoAnnotation] if !exists { return nil, nil } - autoMigration := new(framework.AutoMigrationInfo) - if err := json.Unmarshal([]byte(value), autoMigration); err != nil { + autoMigrationInfo := new(framework.AutoMigrationInfo) + if err := json.Unmarshal([]byte(value), autoMigrationInfo); err != nil { return nil, err } - return autoMigration, nil + return autoMigrationInfo, nil } func getIsStickyClusterFromPolicy(policy fedcorev1a1.GenericPropagationPolicy) bool {