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

Fix: Controller handle Hook errors #7081

Merged
merged 3 commits into from
Dec 7, 2023
Merged

Conversation

N-o-Z
Copy link
Member

@N-o-Z N-o-Z commented Nov 29, 2023

Closes #7075

Change Description

Background

Some operations handled pre hook failures returning the appropriate error code and some operations (such as create branch) did not handle HookAbort Errors and as a result server returned 500

Bug Fix

Fixed by moving the hook error handling to a central location under handleAPIError

Testing Details

Added new system test to cover the scenario

@N-o-Z N-o-Z added bug Something isn't working include-changelog PR description should be included in next release changelog labels Nov 29, 2023
@N-o-Z N-o-Z requested a review from a team November 29, 2023 20:23
@N-o-Z N-o-Z self-assigned this Nov 29, 2023
Comment on lines 38 to 39
branches:
- *
Copy link
Contributor

Choose a reason for hiding this comment

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

Think you can pass empty list []

Comment on lines +2229 to +2234
var hookAbortErr *graveler.HookAbortError
if errors.As(err, &hookAbortErr) {
log.WithField("run_id", hookAbortErr.RunID).Warn("aborted by hooks")
cb(w, r, http.StatusPreconditionFailed, err)
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The HookAbortErr can hold (wrapped by graveler.ErrPreconditionFailed), so the default handler implementation will return http.StatusPreconditionFailed.
All is left is the logging which I think we should keep in all places we trigger hooks and not in the central location.

My two concerns are:

  • logging related to the operation, today we capture run_id tomorrow we will need the full content (ex: source branch and etc)
  • the downside in having central error location is we can't map where this error is being used.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. HookAbortErr already wraps the underlying error from the hook execution.
  2. Logging is coupled with checking that we actually had a HookAbortErr which brings us back to exactly the same situation where we were - missing handling because we forgot to add the same code block in another operation that uses hooks

@N-o-Z N-o-Z requested a review from nopcoder December 3, 2023 12:13
Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

LGTM

@N-o-Z N-o-Z merged commit 96dc40b into master Dec 7, 2023
34 checks passed
@N-o-Z N-o-Z deleted the fix/handle-hook-errors-7075 branch December 7, 2023 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Action errors are not handled in "CreateBranch" and result in 500 response
2 participants