Skip to content

Commit

Permalink
added already exists error
Browse files Browse the repository at this point in the history
  • Loading branch information
henderiw committed May 20, 2024
1 parent 61117f4 commit 8366694
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/reconcilers/resource/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ func IgnoreAny(err error, is ...ErrorIs) error {
func IgnoreNotFound(err error) error {
return Ignore(errors.IsNotFound, err)
}

// IgnoreAlreadyExist returns the supplied error, or nil if the error indicates a
// Kubernetes resource that already exists.
func IgnoreAlreadyExist(err error) error {
return Ignore(errors.IsAlreadyExists, err)
}
5 changes: 4 additions & 1 deletion pkg/resources/recources.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ func (r *Resources) apply(ctx context.Context, o backend.GenericObject) error {
}
if err := r.Client.Create(ctx, o); err != nil {
log.Error("cannot create resource", "key", key.String(), "error", err.Error())
return err
if resource.IgnoreAlreadyExist(err) != nil {
return err
}
return nil
}
return nil
}
Expand Down

0 comments on commit 8366694

Please sign in to comment.