Skip to content

Commit

Permalink
claims: Retry in case the claim get failed
Browse files Browse the repository at this point in the history
In case we try to create a claim, and it already exists,
and then we try to fetch it in order to validate it,
but it was deleted meanwhile, we should retry to reconcile,
in order to give it another chance to be created.

Also no need double check err != nil, as we check it already in this block.

Signed-off-by: Or Shoval <oshoval@redhat.com>
  • Loading branch information
oshoval committed Jul 9, 2024
1 parent 9ebca21 commit c9fa762
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/vminetworkscontroller/vmi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,9 @@ func (r *VirtualMachineInstanceReconciler) Reconcile(

existingIPAMClaim := &ipamclaimsapi.IPAMClaim{}
if err := r.Client.Get(ctx, claimKey, existingIPAMClaim); err != nil {
if apierrors.IsNotFound(err) {
// we assume it had already cleaned up in the few miliseconds it took to get here ...
// TODO does this make sense? ... It's pretty much just for completeness.
continue
} else if err != nil {
return controllerruntime.Result{}, fmt.Errorf("let us be on the safe side and retry later")
}
return controllerruntime.Result{}, fmt.Errorf("let us be on the safe side and retry later")
}

if len(existingIPAMClaim.OwnerReferences) == 1 && existingIPAMClaim.OwnerReferences[0].UID == ownerInfo.UID {
r.Log.Info("found existing IPAMClaim belonging to this VM/VMI, nothing to do", "UID", ownerInfo.UID)
continue
Expand Down

0 comments on commit c9fa762

Please sign in to comment.