Skip to content

Commit

Permalink
EgressIP: Do not throw error on API IsNotFound
Browse files Browse the repository at this point in the history
Do not throw an error when the cache contains a delete operation
for an IsNotFound API object. Instead, log an Info and go on with
the business logic. The desired state is already == the current
state, so there is no reason to throw an error and retry in such
a scenario.

Signed-off-by: Andreas Karis <ak.karis@gmail.com>
  • Loading branch information
andreaskaris committed Jul 28, 2022
1 parent e16d3e5 commit 3d69f04
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions go-controller/pkg/ovn/egressip.go
Expand Up @@ -861,11 +861,18 @@ func (oc *Controller) executeCloudPrivateIPConfigOps(egressIPName string, ops ma
oc.recorder.Eventf(&eIPRef, kapi.EventTypeWarning, "CloudAssignmentFailed", "egress IP: %s for object EgressIP: %s could not be created, err: %v", egressIP, egressIPName, err)
return fmt.Errorf("cloud add request failed for CloudPrivateIPConfig: %s, err: %v", cloudPrivateIPConfigName, err)
}
// toDelete is non-empty, this indicates an DELETE for which
// the object **must** exist, if not: that's an error.
// toDelete is non-empty, this indicates a DELETE - if the object does not exist, log an Info message and continue with the next op.
// The reason for why we are not throwing an error here is that desired state (deleted) == isState (object not found).
// If for whatever reason we have a pending toDelete op for a deleted object, then this op should simply be silently ignored.
// Any other error, return an error to trigger a retry.
} else if op.toDelete != "" {
if err != nil {
return fmt.Errorf("cloud deletion request failed for CloudPrivateIPConfig: %s, could not get item, err: %v", cloudPrivateIPConfigName, err)
if apierrors.IsNotFound(err) {
klog.Infof("Cloud deletion request failed for CloudPrivateIPConfig: %s, item already deleted, err: %v", cloudPrivateIPConfigName, err)
continue
} else {
return fmt.Errorf("cloud deletion request failed for CloudPrivateIPConfig: %s, could not get item, err: %v", cloudPrivateIPConfigName, err)
}
}
if err := oc.kube.DeleteCloudPrivateIPConfig(cloudPrivateIPConfigName); err != nil {
eIPRef := kapi.ObjectReference{
Expand Down

0 comments on commit 3d69f04

Please sign in to comment.