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(api-server): improve error handling and return status #7937

Merged
merged 5 commits into from
Oct 12, 2023

Conversation

lahabana
Copy link
Contributor

@lahabana lahabana commented Oct 2, 2023

  • never return 412 (it was never appropriate
  • create better error hierarchy to simplify handler
  • use in some places errors.Is

Checklist prior to review

  • Link to relevant issue as well as docs and UI issues --
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as a image registry) and it will work on Windows, system specific functions like syscall.Mkfifo have equivalent implementation on the other OS --
  • Tests (Unit test, E2E tests, manual test on universal and k8s) --
  • Do you need to update UPGRADE.md? --
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label) --
  • Do you need to explicitly set a > Changelog: entry here or add a ci/ label to run fewer/more tests?

@lahabana lahabana requested a review from a team as a code owner October 2, 2023 10:39
@lahabana lahabana requested review from bartsmykla and lobkovilya and removed request for a team October 2, 2023 10:39
@jakubdyszkiewicz
Copy link
Contributor

Nice, I like this direction very much. Our error handling bothers me. It would be nice to create a set of rules as we have for logging https://github.com/kumahq/kuma/blob/master/docs/madr/decisions/003-logging.md
to be more specific:

  • When to create a separate type, when to just do errors.Wrap()
  • What functions do you need to define for err
  • What should be the name of the error type and function to create an error

I'm up to writing this down.

@lahabana
Copy link
Contributor Author

lahabana commented Oct 5, 2023

@jakubdyszkiewicz I think it makes sense to have a MADR (also because implementing things like Is is not always straightforward :)

pkg/core/rest/errors/error_handler.go Outdated Show resolved Hide resolved
pkg/core/rest/errors/error_handler.go Show resolved Hide resolved
pkg/core/rest/errors/error_handler.go Show resolved Hide resolved
pkg/core/resources/store/store.go Show resolved Hide resolved
pkg/core/resources/store/store.go Show resolved Hide resolved
pkg/core/resources/store/store.go Show resolved Hide resolved
@bartsmykla
Copy link
Contributor

/golden_files

- never return 412 (it was never appropriate
- create better error hierarchy to simplify handler
- use in some places errors.Is

Signed-off-by: Charly Molter <[email protected]>
Signed-off-by: Charly Molter <[email protected]>
Signed-off-by: Charly Molter <[email protected]>
@lahabana lahabana enabled auto-merge (squash) October 12, 2023 12:20
@lahabana lahabana merged commit beb3c36 into kumahq:master Oct 12, 2023
5 checks passed
@lahabana lahabana deleted the no412 branch March 29, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants