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

Update of sigs.k8s.io/controller-runtime from v0.11.2 -> v0.12.0 makes envtest fails on applying CRD configs #1899

Closed
IoanaIvanova opened this issue May 13, 2022 · 4 comments

Comments

@IoanaIvanova
Copy link

After updating k8s operator dependency sigs.k8s.io/controller-runtime from version v0.11.2 to v0.12.0 the setup of envtest started failing to apply CRDs which are different that the one that the k8s operator describes.

I would like to apply a different CRD (an argo workflow CRD) since the operator operates on changes of argo workflows and I would like to test this without installing a whole argo server but rather simulate changes of workflow CR. So I need to have a workflow CRD in order to have a workflow CR and I managed to do this by adding the argo CRD in a testdata dir in the operator's repo and passing this dir to the suite_test.go with the following code:

	testEnv := &envtest.Environment{
		CRDDirectoryPaths: []string{
			filepath.Join("..", "..", "config", "crd", "bases"),
			filepath.Join("testdata", "workflows", "definition"),
		},
		ErrorIfCRDPathMissing:    true,
		AttachControlPlaneOutput: true,
	}

This works pretty fine before changing sigs.k8s.io/controller-runtime to version v0.12.0 when the envtest started to search in both described directories the name of the CRD that the k8s operator describe rather then applying the CRD which is in the describe directory.

Could you please tell me if this change is a desired one and if yes how I could change the envtest implementation in order to fulfil the need to apply CRD which is not defined in the testing operator?

@stijndehaes
Copy link

I am seeing the same issue

@haugom
Copy link

haugom commented May 16, 2022

I am experiencing the same. I believe its this change that broke it:

6688005#diff-b6b1b02e41870fbffb46bc5880965e53a92a1c6807bb3fae0e8473154fb416a4R307-R314

It seems it doesn't reset the files slice between each path it is looping over.

A workaround for me seems to be to remove the additional crd's from the environment.crd's and add them manually after testEnv.start()

	envtest.InstallCRDs(testEnv.Config, envtest.CRDInstallOptions{
		Paths: []string{
			filepath.Join("..", "somedir", "somepath"),
		},
	})

@IoanaIvanova
Copy link
Author

Thank you @haugom the workaround which you mentioned fix the problem.

@alvaroaleman
Copy link
Member

This got fixed in #1904 and the fix got released in https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.12.1 .

Thanks for your report!

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