From f63c134aa4ce660e76789e3f620556b75b001323 Mon Sep 17 00:00:00 2001 From: changzhen Date: Mon, 21 Oct 2024 21:08:17 +0800 Subject: [PATCH] handle preserveResourceOnDeletion with dependencise distributor Signed-off-by: changzhen --- pkg/dependenciesdistributor/dependencies_distributor.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index 7dad0ba3c149..3c179f949e71 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -546,6 +546,7 @@ func (d *DependenciesDistributor) removeScheduleResultFromAttachedBindings(bindi delete(attachedBindings[index].Labels, bindingLabelKey) updatedSnapshot := deleteBindingFromSnapshot(bindingNamespace, bindingName, attachedBindings[index].Spec.RequiredBy) attachedBindings[index].Spec.RequiredBy = updatedSnapshot + attachedBindings[index].Spec.PreserveResourcesOnDeletion = nil if err := d.Client.Update(context.TODO(), attachedBindings[index]); err != nil { klog.Errorf("Failed to update binding(%s/%s): %v", binding.Namespace, binding.Name, err) errs = append(errs, err) @@ -563,6 +564,7 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding existBinding.Spec.RequiredBy = mergeBindingSnapshot(existBinding.Spec.RequiredBy, attachedBinding.Spec.RequiredBy) existBinding.Labels = util.DedupeAndMergeLabels(existBinding.Labels, attachedBinding.Labels) existBinding.Spec.Resource = attachedBinding.Spec.Resource + existBinding.Spec.PreserveResourcesOnDeletion = attachedBinding.Spec.PreserveResourcesOnDeletion if err := d.Client.Update(context.TODO(), existBinding); err != nil { klog.Errorf("Failed to update resourceBinding(%s): %v", bindingKey, err) @@ -703,7 +705,8 @@ func buildAttachedBinding(independentBinding *workv1alpha2.ResourceBinding, obje Name: object.GetName(), ResourceVersion: object.GetResourceVersion(), }, - RequiredBy: result, + RequiredBy: result, + PreserveResourcesOnDeletion: independentBinding.Spec.PreserveResourcesOnDeletion, }, } }