From 9e857284c6f4dfcb749fd82f2cfe4f9b50c660e9 Mon Sep 17 00:00:00 2001 From: Xinzhao Xu Date: Mon, 17 Jan 2022 16:15:17 +0800 Subject: [PATCH] update first Signed-off-by: Xinzhao Xu --- pkg/detector/detector.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/detector/detector.go b/pkg/detector/detector.go index 95ec3002d8de..a4d65c1e6a51 100644 --- a/pkg/detector/detector.go +++ b/pkg/detector/detector.go @@ -1063,7 +1063,11 @@ func (d *ResourceDetector) ReconcileResourceBinding(key util.QueueKey) error { return nil } - return retry.RetryOnConflict(retry.DefaultRetry, func() error { + if err = retry.RetryOnConflict(retry.DefaultRetry, func() error { + if _, err = d.DynamicClient.Resource(gvr).Namespace(resource.Namespace).UpdateStatus(context.TODO(), newObj, metav1.UpdateOptions{}); err == nil { + return nil + } + obj, err := d.DynamicClient.Resource(gvr).Namespace(resource.Namespace).Get(context.TODO(), resource.Name, metav1.GetOptions{}) if err != nil { return err @@ -1072,11 +1076,14 @@ func (d *ResourceDetector) ReconcileResourceBinding(key util.QueueKey) error { return err } if _, err = d.DynamicClient.Resource(gvr).Namespace(resource.Namespace).UpdateStatus(context.TODO(), obj, metav1.UpdateOptions{}); err != nil { - klog.Errorf("Failed to update resource(%s/%s/%s), Error: %v", resource.Kind, resource.Namespace, resource.Name, err) return err } return nil - }) + }); err != nil { + klog.Errorf("Failed to update resource(%s/%s/%s), Error: %v", resource.Kind, resource.Namespace, resource.Name, err) + return err + } + return nil } // OnClusterResourceBindingAdd handles object add event.