Skip to content

Commit

Permalink
Merge pull request #4721 from chaosi-zju/hpasyncerv2
Browse files Browse the repository at this point in the history
fix deployment replicas syncer in case deployment status changed before label added
  • Loading branch information
karmada-bot authored Mar 20, 2024
2 parents 2d31561 + 3012c80 commit dbb82be
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ var predicateFunc = predicate.Funcs{
return false
}

// if old deployment is not labeled `retain-replicas`, but new is labeled, reconcile is needed.
// in case of deployment status changed before `retain-replicas` labeled.
oldRetainReplicasLabel := util.GetLabelValue(oldObj.GetLabels(), util.RetainReplicasLabel)
if oldRetainReplicasLabel != util.RetainReplicasValue {
return true
}

if oldObj.Spec.Replicas == nil || newObj.Spec.Replicas == nil {
klog.Errorf("spec.replicas field unexpectedly become nil: %+v, %+v", oldObj.Spec.Replicas, newObj.Spec.Replicas)
return false
Expand Down

0 comments on commit dbb82be

Please sign in to comment.