✨ envtest: search the assets index for latest of a release series#3260
✨ envtest: search the assets index for latest of a release series#3260cbandy wants to merge 3 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: cbandy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @cbandy. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
| if errR == nil { | ||
| requestedRange = parsedRange | ||
| } else { | ||
| requestedRange = nil |
There was a problem hiding this comment.
When are we hitting this case and what happens then?
There was a problem hiding this comment.
This would theoretically happen when the input is a tolerated version, and/but the string manipulations produce text that is not a range. As I was writing tests approaching this area, I ran into other edge cases of the blang/semver range parsing and behavior. In the current changeset, this moment is the final return nil, nil of interpretVersion.
When this happens, there is no "search" of the index; binaryAssetsVersion is used directly as the key/lookup in downloadBinaryAssetsArchive. That function errors with:
controller-runtime/pkg/envtest/binaries.go
Lines 222 to 225 in 6824653
Signed-off-by: Chris Bandy <bandy.chris@gmail.com>
|
I've rebased and made the requested changes. I switched from
I left the latest changes as a separate commit in case that helps during review. I'd like to squash this down before merge, tho. Footnotes |
|
|
||
| require ( | ||
| github.com/blang/semver/v4 v4.0.0 | ||
| github.com/Masterminds/semver/v3 v3.4.0 |
There was a problem hiding this comment.
The nice thing about using blang/semver was that we already had this as a dependency and we shared this dependency with k/k.
The nice thing about mostly sticking to k/k's dependencies is that they take care of all the maintenance for us (including sometimes forking abandoned dependencies if necessary).
Now we have an additional dependency that everyone that uses controller-runtime inherits
To be honest, I'm not sure if we can justify this for version parsing in envtest
There was a problem hiding this comment.
I don't really mind to be honest - Its a commonly-used lib and it has zero dependencies itself: https://github.com/Masterminds/semver/blob/bf01c618459762fa583c24476ec46957a330c737/go.mod
There was a problem hiding this comment.
Yeah. I would just try to keep the number of transitive dependencies of CR low (especially the ones we add on top of k8s.io/* transitive dependencies)
There was a problem hiding this comment.
I forgot about these packages:
- https://pkg.go.dev/k8s.io/apimachinery/pkg/version
- https://pkg.go.dev/k8s.io/apimachinery/pkg/util/version
🤔 The fuzzy matching I'm after may just be ParseMajorMinor... lol, no rush on this PR. I'll poke it again before EOW.
I've used the latter package when testing edge cases in SSA over the years:
switch {
case serverVersion.LessThan(version.MustParseGeneric("1.25.15")):
case serverVersion.AtLeast(version.MustParseGeneric("1.26")) && serverVersion.LessThan(version.MustParseGeneric("1.26.10")):
case serverVersion.AtLeast(version.MustParseGeneric("1.27")) && serverVersion.LessThan(version.MustParseGeneric("1.27.7")):
assert.Assert(t, after.GetResourceVersion() != before.GetResourceVersion(),
"expected https://issue.k8s.io/116861")
default:
assert.Assert(t, after.GetResourceVersion() == before.GetResourceVersion())
}
The latter apimachinery package worked well! Rather than add a rewrite here, I'm closing this to be replaced by #3280. Both PRs are about the same size, but the new one seems more straightforward. |
This lets one configure the
DownloadBinaryAssetsVersionfield ofenvtest.Environmentwith only the Major.Minor portions of a Kubernetes API version. WhenDownloadBinaryAssetsis set, the framework will search the asset index for the latest stable version in that release series.This matches the behavior of
setup-envtest use {major}.{minor}without the full complexity of version selectors. The leadingvis now optional, too.For example:
"v1.29"resolves to v1.29.4"1.27"resolves to v1.27.1"1.24"resolves to v1.24.2