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

OpenShift.clean() does not clean custom resources #293

Closed
mchoma opened this issue Jul 3, 2019 · 5 comments
Closed

OpenShift.clean() does not clean custom resources #293

mchoma opened this issue Jul 3, 2019 · 5 comments

Comments

@mchoma
Copy link
Contributor

mchoma commented Jul 3, 2019

I mean we are testing operator which introduce resource api WildFlyServer.wildfly.org. Of course xtf has no idea of such resource.

Now what are options to resolve this? Provide method, such caller can specify additional resources he wants to remove?

Or take another approach similar to oc --loglevel=10 delete all --all. Which seems first take available resource apis and then for each tries to remove resources. (but I have no idea how that can be implemented)

@Crumby
Copy link
Contributor

Crumby commented Jul 3, 2019

It's possible to work with CustomResourceDefinition without knowing its type and thus delete it. But I'm not sure that will work for all CustomResources.

@mchoma
Copy link
Contributor Author

mchoma commented Jul 3, 2019

Could you reference some example of working with CustomResourceDefinition ? Anyway it is cluster scoped resource. I would expect OpenShift.clean() cleans only namespace scoped resources.

@dsimansk
Copy link
Contributor

dsimansk commented Jul 3, 2019

Some examples can be found in fabric8io/kubernetes-client repository.

Working with CustomResourceDefinitions
https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDLoadExample.java
https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/ListCustomResourceDefinitions.java

The first approach with POJOs:
https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/CRDExample.java

The newer API levering raw approach without POJOs:
https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/RawCustomResourceExample.java

AFAIK, there's no definitive and good answer from client devs. They're working on simplifying the whole process. Anyway the former approach required to define POJOs for CustomResources to allow serialization/deserializationa and CRUD operations. There's no way for java client to have a model of custom resource available and the way it's implemented it can manipulate (CRUD) on such resources either.

In Kafka Operator (Java based operator) they do generate class model the same way as in kubernetes-client, because they also leverage the client directly.

IMO the raw approach seems a bit more promising and easier to impl/maintain, but I haven't tried it yet.

Anyway I don't think we can/should add a direct support to XTF for any of the specific CRDs, CRs. That'd make it even more obscure to work with.
@Crumby @maschmid probably something like a clean hook (Java SPI) to be executed afterwards to extend clean capability?

@maschmid
Copy link
Contributor

maschmid commented Jul 3, 2019

It should be possible to use a dynamic client (just for deletion), as you don't have to know anything about the CRDs to delete its CRs. You only need to know the Group, Version and Resource to get the list of CRs and to delete them. (so we could have something like

openshift.clean(new GroupVersionResource("cool.io","v1alpha1", "foos"), new GroupVersionResource("cool.io","v1alpha1", "bars"), ...);

To have clean delete all "all"s, it would only have to list all CRDs that list "all" as its category.. (note that it doesn't necessary mean "all CRDs that exist") , not sure if "oc" use some special API for it (as apparently it knows the list even if the user cannot list CRDs... )

@Crumby
Copy link
Contributor

Crumby commented Aug 29, 2019

Resolved by #299. Closing.

@Crumby Crumby closed this as completed Aug 29, 2019
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

No branches or pull requests

4 participants