fix a bug that Replica set by overridepolicy will be reset by ReviseReplica interpreterhook issue#1347

Signed-off-by: likakuli <1154584512@qq.com>
This commit is contained in:
likakuli 2022-02-10 15:29:28 +08:00
parent ca2997293f
commit f4fc8ee15b
1 changed files with 7 additions and 5 deletions

View File

@ -81,11 +81,6 @@ func ensureWork(
for i := range targetClusters {
targetCluster := targetClusters[i]
clonedWorkload := workload.DeepCopy()
cops, ops, err := overrideManager.ApplyOverridePolicies(clonedWorkload, targetCluster.Name)
if err != nil {
klog.Errorf("Failed to apply overrides for %s/%s/%s, err is: %v", clonedWorkload.GetKind(), clonedWorkload.GetNamespace(), clonedWorkload.GetName(), err)
return err
}
workNamespace, err := names.GenerateExecutionSpaceName(targetCluster.Name)
if err != nil {
@ -116,6 +111,13 @@ func ensureWork(
}
}
// We should call ApplyOverridePolicies last, as override rules have the highest priority
cops, ops, err := overrideManager.ApplyOverridePolicies(clonedWorkload, targetCluster.Name)
if err != nil {
klog.Errorf("Failed to apply overrides for %s/%s/%s, err is: %v", clonedWorkload.GetKind(), clonedWorkload.GetNamespace(), clonedWorkload.GetName(), err)
return err
}
annotations := mergeAnnotations(clonedWorkload, binding, scope)
annotations, err = recordAppliedOverrides(cops, ops, annotations)
if err != nil {