Skip to content

Commit

Permalink
Revert "Fixes (Azure#569)"
Browse files Browse the repository at this point in the history
This reverts commit 1c90db0.
  • Loading branch information
Zhiying Lin committed Oct 20, 2023
1 parent 7268bd5 commit ce50f91
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 407 deletions.
42 changes: 16 additions & 26 deletions pkg/scheduler/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,6 @@ func (f *framework) updatePolicySnapshotStatusFromBindings(
) error {
policyRef := klog.KObj(policy)

// Retrieve the corresponding CRP generation.
observedCRPGeneration, err := annotations.ExtractObservedCRPGenerationFromPolicySnapshot(policy)
if err != nil {
klog.ErrorS(err, "Failed to retrieve CRP generation from annoation", "clusterSchedulingPolicySnapshot", policyRef)
return controller.NewUnexpectedBehaviorError(err)
}

// Prepare new scheduling decisions.
newDecisions := newSchedulingDecisionsFromBindings(f.maxUnselectedClusterDecisionCount, notPicked, filtered, existing...)
// Prepare new scheduling condition.
Expand All @@ -711,16 +704,18 @@ func (f *framework) updatePolicySnapshotStatusFromBindings(
// Compare the new decisions + condition with the old ones.
currentDecisions := policy.Status.ClusterDecisions
currentCondition := meta.FindStatusCondition(policy.Status.Conditions, string(placementv1beta1.PolicySnapshotScheduled))
if observedCRPGeneration == policy.Status.ObservedCRPGeneration &&
equalDecisions(currentDecisions, newDecisions) &&
condition.EqualCondition(currentCondition, &newCondition) {
if equalDecisions(currentDecisions, newDecisions) && condition.EqualCondition(currentCondition, &newCondition) {
// Skip if there is no change in decisions and conditions.
klog.InfoS(
"No change in scheduling decisions and condition, and the observed CRP generation remains the same",
"clusterSchedulingPolicySnapshot", policyRef)
return nil
}

// Retrieve the corresponding CRP generation.
observedCRPGeneration, err := annotations.ExtractObservedCRPGenerationFromPolicySnapshot(policy)
if err != nil {
klog.ErrorS(err, "Failed to retrieve CRP generation from annoation", "clusterSchedulingPolicySnapshot", policyRef)
return controller.NewUnexpectedBehaviorError(err)
}

// Update the status.
policy.Status.ClusterDecisions = newDecisions
policy.Status.ObservedCRPGeneration = observedCRPGeneration
Expand Down Expand Up @@ -1281,13 +1276,6 @@ func (f *framework) updatePolicySnapshotStatusForPickFixedPlacementType(
) error {
policyRef := klog.KObj(policy)

// Retrieve the corresponding CRP generation.
observedCRPGeneration, err := annotations.ExtractObservedCRPGenerationFromPolicySnapshot(policy)
if err != nil {
klog.ErrorS(err, "Failed to retrieve CRP generation from annotation", "clusterSchedulingPolicySnapshot", policyRef)
return controller.NewUnexpectedBehaviorError(err)
}

// Prepare new scheduling decisions.
newDecisions := newSchedulingDecisionsForPickFixedPlacementType(valid, invalid, notFound)
// Prepare new scheduling condition.
Expand All @@ -1303,16 +1291,18 @@ func (f *framework) updatePolicySnapshotStatusForPickFixedPlacementType(
// Compare new decisions + condition with the old ones.
currentDecisions := policy.Status.ClusterDecisions
currentCondition := meta.FindStatusCondition(policy.Status.Conditions, string(placementv1beta1.PolicySnapshotScheduled))
if observedCRPGeneration == policy.Status.ObservedCRPGeneration &&
equalDecisions(currentDecisions, newDecisions) &&
condition.EqualCondition(currentCondition, &newCondition) {
if equalDecisions(currentDecisions, newDecisions) && condition.EqualCondition(currentCondition, &newCondition) {
// Skip if there is no change in decisions and conditions.
klog.InfoS(
"No change in scheduling decisions and condition, and the observed CRP generation remains the same",
"clusterSchedulingPolicySnapshot", policyRef)
return nil
}

// Retrieve the corresponding CRP generation.
observedCRPGeneration, err := annotations.ExtractObservedCRPGenerationFromPolicySnapshot(policy)
if err != nil {
klog.ErrorS(err, "Failed to retrieve CRP generation from annotation", "clusterSchedulingPolicySnapshot", policyRef)
return controller.NewUnexpectedBehaviorError(err)
}

// Update the status.
policy.Status.ClusterDecisions = newDecisions
policy.Status.ObservedCRPGeneration = observedCRPGeneration
Expand Down
Loading

0 comments on commit ce50f91

Please sign in to comment.