Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Event error #1217

Merged
merged 2 commits into from
Sep 15, 2023
Merged

Remove Event error #1217

merged 2 commits into from
Sep 15, 2023

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Aug 28, 2023

Remove deprecated Event error. Event error was used for scenarios where an error should result in an event/notification. It was introduced as a contextual error along with Stalling and Waiting errors but was later replaced with Generic error which doesn't have any contextual meaning. The Generic error provided error configuration which allowed defining how the error should be handled. This replaced the contextual error handling with error action handlers which behaved on the error configuration of the errors.

The Generic error was first introduced to be used in GitRepository reconciler and was used by new reconcilers like the OCIRepository reconcilers. The old reconcilers, bucket, helmrepository and helmchart reconcilers, were still using the deprecated Event error. This change replaces the Event errors in these reconcilers with Generic error.

It also fixes a bug in the Generic error constructor which configured the error to be logged by default. This resulted in an error to be logged by the result processor and the runtime, double logging. This behavior has been changed to not log explicitly and allow the runtime to log the error. Since the Generic error is based on defining the error handling behavior in the error configuration, a generic error that needs to be ignored (not returned to the runtime), but logged can enable the logging behavior explicitly on the Generic error instance. This is done in GitRepository reconciler for no-op reconciliations where an ignore error is returned.

The serial patcher errors are also converted to be a Generic error so that they too are handled like other errors with an associated warning event. A new event reason PatchOperationFailedReason is introduced for such warning events.

Refer #724 for more historic details.

@darkowlzz darkowlzz added the enhancement New feature or request label Aug 28, 2023
@darkowlzz darkowlzz marked this pull request as ready for review September 12, 2023 16:50
@hiddeco
Copy link
Member

hiddeco commented Sep 13, 2023

Something to think about: controller-runtime v0.15.0 introduced a reconcile.TerminalError(...) which may help to eventually get rid and/or reduce these abstractions.

Comment on lines +108 to +109
// PatchOperationFailedReason signals a failure in patching a kubernetes API
// object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// PatchOperationFailedReason signals a failure in patching a kubernetes API
// object.
// PatchOperationFailedReason signals a failure in patching a Kubernetes object.

maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kubernetes API server
Kubernetes API machinery
I don't see much of a difference or improvement. It's not redundant but more specific. I can change if it really (not "maybe") makes any difference for anyone.

Remove deprecated Event error. Event error was used for scenarios where
an error should result in an event/notification. It was introduced as a
contextual error along with Stalling and Waiting errors but was later
replaced with Generic error which doesn't have any contextual meaning.
The Generic error provided error configuration which allowed defining
how the error should be handled. This replaced the contextual error
handling with error action handlers which behaved on the error
configuration of the errors.

The Generic error was first introduced to be used in GitRepository
reconciler and was used by new reconcilers like the OCIRepository
reconcilers. The old reconcilers bucket, helmrepository and helmchart
reconcilers were still using the deprecated Event error. This change
replaces the Event errors in these reconcilers with a Generic error.

It also fixes a bug in the Generic error constructor which configured
the error to be logged by default. This resulted in an error to be
logged by the result processor and the runtime, double logging. This
behavior has been changed to not log explicitly and allow the runtime to
log the error. Since the Generic error is based on defining the error
handling behavior in the error configuration, a generic error that needs
to be ignored (not returned to the runtime), but logged can enable the
logging behavior explicitly on the Generic error instance. This is done
in GitRepository reconciler for no-op reconciliations where an ignore
error is returned.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
Introduce a new event reason for patch operation failure and update all
the returned errors from serial patcher to be a generic error so that
they are handled like any other error with an associated warning event.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
@darkowlzz darkowlzz merged commit 617cfb2 into main Sep 15, 2023
10 checks passed
@darkowlzz darkowlzz deleted the remove-event-error branch September 15, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants