-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use setup-envtest from (test) code #2790
Comments
Yeah, I agree adding code to the |
Agreed, this would definitely be useful! |
Also sounds useful to me, we just have to check what the impact on our dependencies is. setup-envtest today is a separate go module. |
@sbueringer I started porting code over in my fork, and while it's nowhere near ready to actually review yet (loads of local changes that are in a very unpolished - and uncommitted - state at the moment...) the |
Doesn't look like a showstopper to me. indirect dependency bumps look definitely fine Today we're relatively safe as a vast majority of our dependencies are inherited from k/k. So whenever k/k is able to compile, CR is as well. |
Yeah I'd suggest using the stdlibs fs abstraction rather than afero to avoid the added deps |
So far I've focused my efforts on lift-and-shifting the reusable packages from My plan is to
and I can easily add
before I submit it for proper review. |
@tomasaschan Just a heads up. We have to migrate the envtest binaries from the GCS bucket to controller-tools releases. This will require some refactoring to setup-envtest to make it possible to pull from this new location. It should be mostly orthogonal to your work, but just wanted to let you know. I'm working on this now. Probably the location change has to merge first as we probably want to backport it (we don't know at which point the old location will go away, because the GCS bucket is owned by Google and not the community) |
@sbueringer Will the code remain in the same github repo, or move to its own? I just locally added a dependency from setup-envtest to the main controller-runtime module in order to make the cli use the new implementation; will that, in the long term, be an issue? I guess the worst case is that my changes will end up needing PRs to multiple repos. We'll cross that bridge when we get there. |
Same repo, same packages. I'll just add an alternate implementation for the client stuff |
Very early prototype to give you an impression: https://github.com/kubernetes-sigs/controller-runtime/compare/main...sbueringer:controller-runtime:pr-setup-envtest-ct-rel?expand=1 (I'll try to get this done ASAP, hopefully within the next week or so there should be a PR up) |
@sbueringer Ah, I see. I think that should be fine; I've moved the The main thing to keep in mind is that there should be a good way to configure a "default" client if the user provides no parameters. |
Do we still need a separate module for setup-envtest? If it doesn' introduce any additional dependency anymore I would get rid of it entirely (so folks can do Today people have to pin to commits which is one reason why we were thinking about moving the binary into a separate repository. But If we can get rid of the additional module that all becomes easier. |
I don't particularly mind; we might as well use the same module for everything. I (and the I guess one argument for keeping them separate is that it makes it possible to add some dependencies to setup-envtest that don't have to bloat the dependency tree of controller-runtime itself. For example, the main method is currently quite bloated with both arg parsing and help text etc, and it might be nice to at some point port that to use something like Cobra; but Cobra is currently not a dependency for |
@sbueringer I opened a draft PR with my changes so far, so you can have a look at it if you'd like. Not a whole lot more work to do, but how much time I have to spend on this is a little unpredictable - I might be able to mark it ready for review later today, or not until in a couple of weeks 😅 |
PR is ready for review: #2811 |
#2811 is merged, so this work should be unblocked now |
Sweet! Then I just have to find time to work on this, too 😅 |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
remove-lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten Sorry pretty low bandwith at the moment (and this won't change soon). But still on my radar to review #2810 |
Same, following along and took a look at the PR. One pre-requisite I'd say we need to think about is that today it's possible to use setup envtest to create a container image to be used in isolated environment (without an internet connection). We need to ensure that if binaries are already available locally, we don't make any calls outside and it's still possible to setup envtest images this way; or maybe eventually we could think about offering base images as well. |
@vincepri I'm pretty sure that's a use case that is explicitly covered by tests, so that should be fine. |
I like being able to run the tests of a project with simply
go test ./...
, without requiring any local setup before that (other than a Go toolchain of the appropriate version being available). If one usesenvtest
to mock a Kubernetes cluster, one is expected to run some version ofsetup-envtest
, to ensure the appropriate binaries are available; typically either like thisor e.g.
Other than
setup-envtest
being written with purely this use case in mind, there's no technical reason we couldn't allow triggering this from within the test harness, rather than outside of it.Here's a proof-of-concept implementation that runs the relevant parts of
setup-envtest
triggered from within the test instead, allowingeven for tests that use envtest.
The main reason it's not very straightforward to write this code, is that the error handling in
setup-envtest
is based on panic-and-recover, rather than passing error values. But it also feels a bit odd to go into the internals of the tool, rather than the tool being built to support the use case in the first place.If I send a PR to make this a supported feature and use case for setup-envtest, what are the chances of that being accepted? :)
The text was updated successfully, but these errors were encountered: