Skip to content

Commit c20b55a

Browse files
committed
retry if possible when set bound state
Signed-off-by: roc <[email protected]>
1 parent 9c6762b commit c20b55a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/controller/clbbinding.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,20 @@ func (r *CLBBindingReconciler[T]) ensureBackendBindings(ctx context.Context, bd
405405
cost := time.Since(bd.GetCreationTimestamp().Time)
406406
log.FromContext(ctx).V(3).Info("binding performance", "cost", cost.String())
407407
r.Recorder.Event(bd.GetObject(), corev1.EventTypeNormal, "AllBound", "all targets bound to listener")
408-
status.State = networkingv1alpha1.CLBBindingStateBound
409-
status.Message = ""
410-
if err := r.Status().Update(ctx, bd.GetObject()); err != nil {
408+
if err := util.RetryIfPossible(func() error {
409+
_, err := bd.FetchObject(ctx, r.Client)
410+
if err != nil {
411+
return err
412+
}
413+
status := bd.GetStatus()
414+
status.State = networkingv1alpha1.CLBBindingStateBound
415+
status.Message = ""
416+
return r.Status().Update(ctx, bd.GetObject())
417+
}); err != nil {
411418
return errors.WithStack(err)
412419
}
413420
}
421+
414422
// 确保 status 注解正确
415423
if err := r.ensureBackendStatusAnnotation(ctx, bd, backend); err != nil {
416424
return errors.WithStack(err)

0 commit comments

Comments
 (0)