-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Integration tests do not have gitVersion information #128711
Comments
/triage accepted |
Yeah, that seems like an oversight.
I really don't think we want something we have to bump manually every release. We should be talking to Depending on that we can update the makefile or repo management processes. |
@BenTheElder: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/sig architecture |
We definitely have other components using component-base outside of the repo and injecting the git version. I don't think the integration tests (as opposed to unit tests) or e2e tests are considered to generally support |
that's a little unfortunate, I use |
I disagree here too. |
I mean certainly e2e tests do not. I don't think integration tests have advertised it and you have to do workarounds like making sure you have an appropriate etcd up manually.
This is something we could specifically address. I do not think we should be checking in hard-coded version metadata, and I do think it's reasonable for integration tests to use that metadata. You could always |
I'm sympathetic to preferring that |
For e2e and |
Unit tests also might depend on knowing the current Kubernetes version.
This is done automatically by the test when run via
This is covered by Go itself these days.
So you want to move to a model where there is no versioning information committed at all to any file in the repo and the version gets injected only via make rules based on parameters, the environment or git tags?
And I am not using it. I can't speak for others, but I prefer to work with pure Go when developing code. |
possibly
That's ... not quite true currently. We still use .go-version to wire this in. The go version in the module is the language level, not the toolchain. (it's possible to move this into the module definition, but that's a can of worms we haven't opened yet) If you're not manually matching it or using the makefile, you're not using the supported / tested toolchain version.
This was the case until we added DefaultBinaryVersion. We have never checked-in the version previously.
We've made lots of use of build tags, compiler options, and other features previously. We need them less today, but refusing to use them is counter-productive. I mean, the e2e tests can't even be run with "pure go" anyhow, you have to build container images and bring up a cluster ... |
It's worth noting that we failed to update DefaultBinaryVersion and it got out of sync with the actual major.minor version at the beginning of 1.32 for some time, and proved to be challenging to correct. We really shouldn't have two sources of truth, and I don't see checked-in data replacing the git tags, so the arguments about "pure go" are a distraction. There should not be two sources of version information, and checked-in information is incapable of reasonably replacing the git build metadata. We could have tests not rely on the current version, and they probably shouldn't where feasible. |
Let's face it: that's how most of the developers work. They edit the code in an IDE with language support and run tests without using make. It might not be supported and might not always work, but it seems "good enough" in practice and is more productive than doing everything the "official" way through make. I don't know what that means for versioning. Perhaps the code which depends on the version needs to detect that it has no version and then react more gracefully?
As with integration tests and installing etcd that is something that has do be done beforehand. Once it's done, E2E tests can run just fine with plain |
Uh, I don't think we can assert how most Kubernetes contributors are running the integration tests. There's no data. I think most contributors aren't running these at all, and letting CI do it for them.
... but that's the point. We shouldn't maintain two sources of truth just because some people don't want to run the makefiles for those tests, which sometimes happens to work with other test cases. |
Getting reliable coverage in CI and not de-syncing the version info is more important than attempting to make all test cases work without using the supported make / shell targets. It's not like we're prohibiting running the other tests cases, or running |
When you're running the integration tests with If you happen to need to work on the few that reference version info, that would be the only time that just using Most tests have no business reading the current version, which is why you've been able to ignore this so far, DefaultBinaryVersion is a very recent addition, other tests are clearly not reading it given we haven't been injecting any other version info to the integration tests. |
I'm talking about how contributors work with the source code, not how they run integration tests. I think it is safe to say that they are using some kind of IDE, which then probably also includes running tests through the IDE, at least for unit testing. Whether that extends to integration tests depends on whether they have etcd available. What we do know is that both Jordan and I run those without make.
Every integration test runs the apiserver and thus needs version metadata to correctly warn about obsolete APIs - that is what triggered this whole discussion. With "react more gracefully" I meant that if the apiserver gets started without version information, perhaps it shouldn't warn about those APIs because it simply cannot determine whether they are obsolete? |
one wrinkle is that from code freeze to release, master and the release branch have identical code, but different git tags master is 1.$next.0-alpha.0, release branch is 1.$current... If we switch to pulling from git tags, this means all tests have to pass with both versions... I'm not sure that's always possible to do while still testing what the tests expect to test. Being able to specify the version for a test might be needed in that case ("test as if I'm 1.32", "test as if I'm 1.33", etc). Tests that don't specify, but are coded against the current default version are likely to immediately fail on master when we branch, creating an issue similar to #128616 |
Sure, some of them use IDEs, and then run unit tests that way, and above I suggested we probably shouldn't make unit tests depend on those. You can fairly reliably just click "run test" for unit tests in an IDE. integration and e2e tests are not quite the same though, and I don't think it's reasonable that every integration/e2e test must work this way. We fully expect the e2e tests to be invoked with ginkgo, through the bash, and we are NOT testing that they work with "pure go", same for the integration tests. We shouldn't be requiring a mode of operation we don't test. I'm not advocating that we go breaking all tests, but I think the tradeoff is more than reasonable for the handful of tests that want to be aware of the current version and feature gate enablement.
I see, I guess I am advocating that we break all the integration tests without the proper version variables then :-) I don't think this is a valid mode for starting api-server, it should refuse to start without knowing the current version, we can't correctly default. We could allow setting the version via a single flag, we actually already have an api-server binary flag for telling it to override the version info), but you'd be responsible for correctly setting it. You could use something like
This is already the case for the e2e tests around this behavior: #129060 The point is the correct version did change on those branches and the test should be designed to handle it or the test it's very useful. Very soon that release branch will be the release and master will be the next release "for real". These tests are broken if they aren't prepared for the transition to the next release.
IMHO: They really need to not fail without hacking around it. This is causing real pain regardless of the source of version info. We can't have weeks of trying to get the version updated after cutting a release, every release. |
the flag is https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/ |
We could probably hack up some other fallback mode around https://pkg.go.dev/go/build#Package, but in CI and the make scripts we should prefer the single-source-of-truth instead of Go's own version codepaths (which won't quite match our binary versions, and we can't break that API) or hard-coding. But that still leaves, regardless: we need to make N+1 version less brittle. We need to figure out how to test this feature in a way that tolerates the next release without manual fixups. |
@aojea that's:
|
https://pkg.go.dev/go/build#Package doesn't have versioning information as of Go 1.23, or am I blind? |
Originally raised by @pohly. https://kubernetes.slack.com/archives/C0EG7JC6T/p1730965005279489
kubernetes/staging/src/k8s.io/apiserver/pkg/endpoints/deprecation/deprecation.go
Lines 74 to 77 in 530278b
Current major and minor are both zero, so (all?) non-GA APIs are considered deprecated. I wonder whether that return true should be a return false.
This occurs because k8s.io/component-base/version depends on build flags to inject the git version. This injection does not happen when using go test manually (of course) but also not when using make test (might be an oversight that can be fixed).
version.DefaultKubeBinaryVersion might be a better source of the major/minor version but we do have an issue to remove it in the future #126686
/cc @BenTheElder
/sig testing
The text was updated successfully, but these errors were encountered: