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

handling Kubernetes Errors #51

Open
lswith opened this issue Sep 18, 2018 · 5 comments
Open

handling Kubernetes Errors #51

lswith opened this issue Sep 18, 2018 · 5 comments

Comments

@lswith
Copy link

lswith commented Sep 18, 2018

The StatusError that is returned when a call from kubernetes doesn't succeed would be useful.

Currently its just being decoded https://github.com/obmarg/kazan/blob/master/lib/kazan/client/imp.ex#L160

@obmarg
Copy link
Owner

obmarg commented Sep 22, 2018

Hello again @lswith - is there a specific use case that you've got where a decoded map isn't good enough?

I guess the main problem with errors from k8s is that the swagger spec doesn't give us any details on them. It'd be possible for me to write a struct manually and decode into that, but I'd need to pay attention to the k8s code to make sure that we didn't get out of sync in the future...

@lswith
Copy link
Author

lswith commented Sep 24, 2018

So with regards to the struct, it's actually a generic Status https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go#L40

Here is the main use case:
To determine if a job exists, I need to look the job up. There are 2 possibilities: Get all jobs and iterate through them myself or ask kubernetes for the job and parse the error that is returned. The NotFound error is extremely useful and has many use cases such as the one above.

I do understand though that this library is swagger -> Elixir codegen so it might be hard to implement. It might be worth doing though simply because if its not in the library, it'll have to be implemented by your users. Your users will also be syncing with k8s as well, but now it's custom and everyone will have to do it.

@lswith
Copy link
Author

lswith commented Sep 24, 2018

I'm going to try and find out why k8s hasn't implemented their errors into the OpenAPI.

@obmarg
Copy link
Owner

obmarg commented Sep 24, 2018

Looking into this a tiny bit more, it seems like the StatusError contains a metaStatus, which is actually in the kube specs, and the kazan struct is here so it might be possible for kazan to parse one of these out on error...

@lswith
Copy link
Author

lswith commented Sep 29, 2018

If your curious, I’ve opened a ticket on the kubernetes api machinery to have these errors in the OpenAPI spec:

kubernetes/kubernetes#69014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants