Skip to content

Commit

Permalink
check errors for IsNotFound after patching status/spec
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Connor <[email protected]>
  • Loading branch information
troy0820 committed Jul 11, 2024
1 parent 075517f commit 1a51016
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions util/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,19 @@ func (h *Helper) Patch(ctx context.Context, obj client.Object, opts ...Option) e
if err := h.patch(ctx, obj); err != nil {
errs = append(errs, err)
}

if err := h.patchStatus(ctx, obj); err != nil {
errs = append(errs, err)
}

if obj.GetDeletionTimestamp() != nil && len(obj.GetFinalizers()) == 0 && len(errs) > 0 {
for _, err := range errs {
if ok := apierrors.IsNotFound(err); ok {
return nil
}
}
}

if len(errs) > 0 {
return errors.Wrapf(kerrors.NewAggregate(errs), "failed to patch %s %s", h.gvk.Kind, klog.KObj(h.beforeObject))
}
Expand Down

0 comments on commit 1a51016

Please sign in to comment.