Skip to content

Commit

Permalink
update first
Browse files Browse the repository at this point in the history
Signed-off-by: Xinzhao Xu <[email protected]>
  • Loading branch information
iawia002 committed Jan 17, 2022
1 parent 56cd871 commit 9e85728
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down

0 comments on commit 9e85728

Please sign in to comment.