resource's annotation have not been updated after the overridepolicy updated
Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
parent
9e822a74ca
commit
5154ba4b37
|
@ -11,3 +11,10 @@ func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annot
|
|||
objectAnnotation[annotationKey] = annotationValue
|
||||
obj.SetAnnotations(objectAnnotation)
|
||||
}
|
||||
|
||||
// MergeAnnotations merges the annotations from 'src' to 'dst'.
|
||||
func MergeAnnotations(dst *unstructured.Unstructured, src *unstructured.Unstructured) {
|
||||
for key, value := range src.GetAnnotations() {
|
||||
MergeAnnotation(dst, key, value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -670,6 +670,7 @@ func (d *ResourceDetector) OnPropagationPolicyAdd(obj interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Create PropagationPolicy(%s)", key)
|
||||
d.policyReconcileWorker.AddRateLimited(key)
|
||||
}
|
||||
|
||||
|
@ -680,7 +681,13 @@ func (d *ResourceDetector) OnPropagationPolicyUpdate(oldObj, newObj interface{})
|
|||
|
||||
// OnPropagationPolicyDelete handles object delete event and push the object to queue.
|
||||
func (d *ResourceDetector) OnPropagationPolicyDelete(obj interface{}) {
|
||||
d.OnPropagationPolicyAdd(obj)
|
||||
key, err := ClusterWideKeyFunc(obj)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Delete PropagationPolicy(%s)", key)
|
||||
d.policyReconcileWorker.AddRateLimited(key)
|
||||
}
|
||||
|
||||
// ReconcilePropagationPolicy handles PropagationPolicy resource changes.
|
||||
|
@ -717,6 +724,7 @@ func (d *ResourceDetector) OnClusterPropagationPolicyAdd(obj interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Create ClusterPropagationPolicy(%s)", key)
|
||||
d.clusterPolicyReconcileWorker.AddRateLimited(key)
|
||||
}
|
||||
|
||||
|
@ -727,7 +735,13 @@ func (d *ResourceDetector) OnClusterPropagationPolicyUpdate(oldObj, newObj inter
|
|||
|
||||
// OnClusterPropagationPolicyDelete handles object delete event and push the object to queue.
|
||||
func (d *ResourceDetector) OnClusterPropagationPolicyDelete(obj interface{}) {
|
||||
d.OnClusterPropagationPolicyAdd(obj)
|
||||
key, err := ClusterWideKeyFunc(obj)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
klog.V(2).Infof("Delete ClusterPropagationPolicy(%s)", key)
|
||||
d.clusterPolicyReconcileWorker.AddRateLimited(key)
|
||||
}
|
||||
|
||||
// ReconcileClusterPropagationPolicy handles ClusterPropagationPolicy resource changes.
|
||||
|
@ -748,6 +762,8 @@ func (d *ResourceDetector) ReconcileClusterPropagationPolicy(key util.QueueKey)
|
|||
klog.Infof("Policy(%s) has been removed", ckey.NamespaceKey())
|
||||
return d.HandleClusterPropagationPolicyDeletion(ckey.Name)
|
||||
}
|
||||
|
||||
klog.Errorf("Failed to get Policy(%s): %v", ckey.NamespaceKey(), err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ func RetainClusterFields(desiredObj, clusterObj *unstructured.Unstructured) erro
|
|||
// Pass the same ResourceVersion as in the cluster object for update operation, otherwise operation will fail.
|
||||
desiredObj.SetResourceVersion(clusterObj.GetResourceVersion())
|
||||
|
||||
// Retain finalizers and annotations since they will typically be set by
|
||||
// Retain finalizers since they will typically be set by
|
||||
// controllers in a member cluster. It is still possible to set the fields
|
||||
// via overrides.
|
||||
desiredObj.SetFinalizers(clusterObj.GetFinalizers())
|
||||
desiredObj.SetAnnotations(clusterObj.GetAnnotations())
|
||||
// Merge annotations since they will typically be set by controllers in a member cluster
|
||||
// and be set by user in karmada-controller-plane.
|
||||
util.MergeAnnotations(desiredObj, clusterObj)
|
||||
|
||||
if targetKind == util.PodKind {
|
||||
return retainPodFields(desiredObj, clusterObj)
|
||||
|
|
|
@ -67,7 +67,7 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
|||
ginkgo.By(fmt.Sprintf("creating policy(%s/%s)", policyNamespace, policyName), func() {
|
||||
_, err := karmadaClient.PolicyV1alpha1().PropagationPolicies(policyNamespace).Create(context.TODO(), policy, metav1.CreateOptions{})
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
klog.Infof("created policy(%s)", policyNamespace, policyName)
|
||||
klog.Infof("created policy(%s/%s)", policyNamespace, policyName)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue