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

Substitute K8s API errors with our own classes #575

Merged
merged 2 commits into from Nov 11, 2020
Merged

Substitute K8s API errors with our own classes #575

merged 2 commits into from Nov 11, 2020

Conversation

nolar
Copy link
Owner

@nolar nolar commented Nov 11, 2020

aiohttp is currently the underlying client library, and it raises its response errors. To enrich them with K8s's own explanations, the errors were extended by inheriting from the client library in #558. But anyway, this violates the principle that the API/HTTP client library is isolated to kopf.clients, and no single piece of it leaks outside to other packages (for replaceability).

Instead, introduce our own hierarchy of exceptions for K8s API errors, which are completely independent of the underlying library. The only connection to the original exceptions will be error chaining (raise ... from ...).

This allows us to analyse the API errors in other packages without coupling to the underlying library, while keeps the goal of readable stack traces and error explanations in the logs.

@nolar nolar added the refactoring Code cleanup without new features added label Nov 11, 2020
@lgtm-com
Copy link

lgtm-com bot commented Nov 11, 2020

This pull request introduces 1 alert when merging 6c16c4a into 8023ea4 - view on LGTM.com

new alerts:

  • 1 for Unused import

`aiohttp` is currently the underlying client library, and it raises its response errors. To enrich them with K8s's own explanations, the errors were extended by inheriting from the client library in #558. But anyway, this violates the principle that the API/HTTP client library is isolated to `kopf.clients`, and no single piece of it leaks outside to other packages (for replaceability).

Instead, introduce our own hierarchy of exceptions for K8s API errors, which are completely independent of the underlying library. The only connection to the original exceptions will be error chaining (`raise ... from ...`).

This allows us to analyse the API errors in other packages without coupling to the underlying library, while keeps the goal of readable stack traces and error explanations in the logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code cleanup without new features added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant