cleanup: remove label when pp is deleted

Signed-off-by: zhzhuang-zju <m17799853869@163.com>
This commit is contained in:
zhzhuang-zju 2024-01-12 14:11:23 +08:00
parent 181af49291
commit 774b9dcad2
1 changed files with 6 additions and 6 deletions

View File

@ -1144,14 +1144,14 @@ func (d *ResourceDetector) HandlePropagationPolicyDeletion(policyNS string, poli
// Must remove the labels from the resource template ahead of ResourceBinding, otherwise might lose the chance
// to do that in a retry loop(in particular, the label was successfully removed from ResourceBinding, but
// resource template not), since the ResourceBinding will not be listed again.
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.PropagationPolicyNamespaceLabel, policyv1alpha1.PropagationPolicyNameLabel); err != nil {
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.PropagationPolicyNamespaceLabel, policyv1alpha1.PropagationPolicyNameLabel, policyv1alpha1.PropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from resource(%s-%s/%s) when propagation policy(%s/%s) removing, error: %v",
binding.Spec.Resource.Kind, binding.Spec.Resource.Namespace, binding.Spec.Resource.Name, policyNS, policyName, err)
return err
}
// Clean up the labels from the reference binding so that the karmada scheduler won't reschedule the binding.
if err := d.CleanupResourceBindingLabels(&rbs.Items[index], policyv1alpha1.PropagationPolicyNamespaceLabel, policyv1alpha1.PropagationPolicyNameLabel); err != nil {
if err := d.CleanupResourceBindingLabels(&rbs.Items[index], policyv1alpha1.PropagationPolicyNamespaceLabel, policyv1alpha1.PropagationPolicyNameLabel, policyv1alpha1.PropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from resource binding(%s/%s) when propagation policy(%s/%s) removing, error: %v",
binding.Namespace, binding.Name, policyNS, policyName, err)
return err
@ -1181,7 +1181,7 @@ func (d *ResourceDetector) HandleClusterPropagationPolicyDeletion(policyName str
// Must remove the labels from the resource template ahead of ClusterResourceBinding, otherwise might lose the chance
// to do that in a retry loop(in particular, the label was successfully removed from ClusterResourceBinding, but
// resource template not), since the ClusterResourceBinding will not be listed again.
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.ClusterPropagationPolicyLabel); err != nil {
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.ClusterPropagationPolicyLabel, policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from resource(%s-%s) when cluster propagation policy(%s) removing, error: %v",
binding.Spec.Resource.Kind, binding.Spec.Resource.Name, policyName, err)
errs = append(errs, err)
@ -1190,7 +1190,7 @@ func (d *ResourceDetector) HandleClusterPropagationPolicyDeletion(policyName str
}
// Clean up the labels from the reference binding so that the karmada scheduler won't reschedule the binding.
if err := d.CleanupClusterResourceBindingLabels(&crbs.Items[index], policyv1alpha1.ClusterPropagationPolicyLabel); err != nil {
if err := d.CleanupClusterResourceBindingLabels(&crbs.Items[index], policyv1alpha1.ClusterPropagationPolicyLabel, policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from cluster resource binding(%s) when cluster propagation policy(%s) removing, error: %v",
binding.Name, policyName, err)
errs = append(errs, err)
@ -1208,7 +1208,7 @@ func (d *ResourceDetector) HandleClusterPropagationPolicyDeletion(policyName str
// Must remove the labels from the resource template ahead of ResourceBinding, otherwise might lose the chance
// to do that in a retry loop(in particular, the label was successfully removed from ResourceBinding, but
// resource template not), since the ResourceBinding will not be listed again.
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.ClusterPropagationPolicyLabel); err != nil {
if err := d.CleanupLabels(binding.Spec.Resource, policyv1alpha1.ClusterPropagationPolicyLabel, policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from resource(%s-%s/%s) when cluster propagation policy(%s) removing, error: %v",
binding.Spec.Resource.Kind, binding.Spec.Resource.Namespace, binding.Spec.Resource.Name, policyName, err)
errs = append(errs, err)
@ -1217,7 +1217,7 @@ func (d *ResourceDetector) HandleClusterPropagationPolicyDeletion(policyName str
}
// Clean up the labels from the reference binding so that the karmada scheduler won't reschedule the binding.
if err := d.CleanupResourceBindingLabels(&rbs.Items[index], policyv1alpha1.ClusterPropagationPolicyLabel); err != nil {
if err := d.CleanupResourceBindingLabels(&rbs.Items[index], policyv1alpha1.ClusterPropagationPolicyLabel, policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel); err != nil {
klog.Errorf("Failed to clean up label from resource binding(%s/%s) when cluster propagation policy(%s) removing, error: %v",
binding.Namespace, binding.Name, policyName, err)
errs = append(errs, err)