-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Test fails with no matches for kind \"Route\" although routev1 is added to schema #4434
Comments
HI @varshaprasad96 @rashmigottipati, It is related to our chat. some references:
It is something that we could maybe doc in upstream/kb and link here. Upstream is also missing a docs related.
|
@camilamacedo86 I understand that the code I expected to work as in kubernetes-sigs/kubebuilder#1772 (comment) is not working. |
Hi @avrahams, It might be missing some detail. To solve this issue, IHMO is required to do a POC and a few checks. Then, properly doc that as well. By solving this one we might be able to close kubernetes-sigs/controller-runtime#1191 as well. |
@varshaprasad96 will try to reproduce this. While kubernetes-sigs/controller-runtime#1191 might be the root cause, we are not sure. /assign @varshaprasad96 |
Shows that for ENV TEST we need also update the CRDDirectoryPath to pass the right info. In this way, to solve this issue we just need to confirm that by doing this test with for example |
While adding the CRDs seems to work, in case of OpenShift API resources it is a bit cumbersome. Since the api is not published via tags I have to use pseudo-versions. Keeping the CRD paths in this format in sync with the Storing the CRDs as fixtures in the project repository would also be possible, but that still would require to manually put them there each time I update the Another question: |
Hi @mpreu, External types are not officially supported by the tool yet. I mean the tool is not prepared for dealing with this scenario and users need to change the files manually. However, see that we have an issue to starts to support in upstream. Then, it will also be applied in SDK. See: kubernetes-sigs/kubebuilder#1999 And then, I also understand that we need to check here how is the best approach to set up the CRD paths for external-types for Envtest in order to solve this scenario. I mean, we need to confirm if the solution described by you still the best/recommended way to do it. |
I am facing the same issue with envtest even though I am not adding any external CRDs. Getting no matches for kind... |
@mpreu I don't see how this is a generally solvable problem unfortunately, since CRDs can be hosted anywhere for any project your operator depends on (doesn't have to be a k8s distro's APIs either, they could be another operator's). operator-sdk is meant to be general, i.e. doesn't specifically target OCP but does support it, but can't know where all distro's/operator's CRDs are hosted and appropriately download/version them. The best operator-sdk could do is wrap
I would bring this issue up in the openshift/api repo.
@ahalim-intel you'll have to download the CRD manifests and reference them during envtest setup. I've confirmed that this issue is a duplicate of kubernetes-sigs/controller-runtime#1191, so all conversation should be moved to that issue. I'm going to close this with an FAQ update. /remove-triage needs-information |
Have submitted a PR upstream (kubernetes-sigs/controller-runtime#1393) to document this. |
Hi All, So basically with generated suite_test.go we get:
Since adding multi-group api puts everything one directory down we needed to add additional ".." to the filepath. So, adding that solved my particular problem.
Took to me a good while to figure this simple error. I think this should added in somewhere like here? I hope someone facing similar issue find this helpful. |
Hi @ahalim-intel,
When you enable multi-group then the new scaffolds will be generating with the path changed as you described. However, it should be described in the doc linked by you too. WDYT about help us and push a PR to update it? Here is the place: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/migration/multi-group.md |
Hi @camilamacedo86,
I've submitted a PR as suggested. PTAL kubernetes-sigs/kubebuilder#2054 |
Update: for OCP and in general externally-defined APIs that use extra-CRD validation, like webhooks and custom apiserver imperative validation, there is no good solution for this problem with envtest; positive test outcomes can be misleading if CRDs alone are used because some other validation could fail server-side in prod. Therefore OCP CRDs alone cannot solve this issue. These facts should be documented in the envtest library, and an FAQ should be added for like-kind errors with this explanation. /remove-triage duplicate |
This is similar to the upstream issue (kubernetes-sigs/controller-runtime#1191). This needs to be handled upstream since envtest library needs more documentation. |
@camilamacedo86, |
Thanks a lot! |
Bug Report
What did you do?
I am following the code skeleton for writing test for controllers
Since my controller also uses openshift routes I added the route to the schema
What did you expect to see?
I expected the manager to start in the test suite without errors as it does in runtime
What did you see instead? Under which circumstances?
After manager.start is called the test fails with no matches for kind "Route" error
Environment
Operator type:
/language go
Kubernetes cluster type:
OpenShift
$ operator-sdk version
operator-sdk version: "v1.2.0", commit: "215fc50b2d4acc7d92b36828f42d7d1ae212015c", kubernetes version: "v1.18.8", go version: "go1.15.3", GOOS: "linux", GOARCH: "amd64"
$ go version
(if language is Go)go version go1.15.6 linux/amd64
$ kubectl version
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: