Skip to content

Commit

Permalink
Merge pull request #83 from adyanth/bug-82-finalizer
Browse files Browse the repository at this point in the history
🐛 Update resource after setting finalizer
  • Loading branch information
adyanth authored Apr 11, 2023
2 parents 6a91681 + 2d32c6d commit c38e0cc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/tunnelbinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (r *TunnelBindingReconciler) creationLogic() error {

// Update TunnelBinding resource
if err := r.Update(r.ctx, r.binding); err != nil {
r.Recorder.Event(r.binding, corev1.EventTypeWarning, "FailedMetaSet", "Failed to set TunnelBinding Finalizer and Labels")
r.Recorder.Event(r.binding, corev1.EventTypeWarning, "FailedMetaSet", "Failed to set Labels")
return err
}

Expand All @@ -269,7 +269,15 @@ func (r *TunnelBindingReconciler) creationLogic() error {
}

if !controllerutil.ContainsFinalizer(r.binding, tunnelFinalizer) {
controllerutil.AddFinalizer(r.binding, tunnelFinalizer)
if !controllerutil.AddFinalizer(r.binding, tunnelFinalizer) {
r.Recorder.Event(r.binding, corev1.EventTypeWarning, "FailedMetaSet", "Failed to set Finalizer")
return fmt.Errorf("failed to set finalizer, trying again")
}
// Update TunnelBinding resource
if err := r.Update(r.ctx, r.binding); err != nil {
r.Recorder.Event(r.binding, corev1.EventTypeWarning, "FailedMetaSet", "Failed to set Finalizer")
return err
}
}

r.Recorder.Event(r.binding, corev1.EventTypeNormal, "MetaSet", "TunnelBinding Finalizer and Labels added")
Expand Down

0 comments on commit c38e0cc

Please sign in to comment.