-
Notifications
You must be signed in to change notification settings - Fork 40.4k
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
Build Kubernetes binaries with valid Semantic Version #57445
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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/test-infra repository. I understand the commands that are listed here. |
I just signed the CLA. |
/ok-to-test |
What created an invalid version which caused this to be a problem and require a patch? |
Is this related to #57420 ? |
This PR doesn't tweak the previous stanza to pull out the minor and major versions like in #57420. In addition, the regex doesn't match on |
@eparis The K8s Conformance test will fail if the version string contains two @rphillips It does match the version string As I understand, the I know this is not a perfect one, but covers more cases. |
@chenzhiwei I tried this regex in bash, and it failed to parse. see an issue with the script? #!/usr/bin/env bash
if [[ "v1.111.0+me.0" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-][0-9A-Za-z+-.]*|[+][0-9A-Za-z.]+)?$ ]] ; then
echo "matched"
fi |
@rphillips here is my result, I just copied your code:
By the way, seems I just submitted another patch which covers more cases.
Let me describe the last element in
As said in https://semver.org/, the identifiers after |
426c265
to
bbfd48b
Compare
the tweak to the regex fixed the parse issue for me. Thanks! |
/retest |
My question is 'where did the 'illegal' version come from that caused you to write this PR? You say:
What is creating something with 2 +'s? It seems to me like the whole point of this PR is to break whatever is doing that, not fix that thing and prevent it from coming back. Show/explain to me how/why this is not a regression. |
This is to restrict the KUBE_GIT_VERSION to fully match the Semantic Version rules. Sometimes, when a user build a Kubernetes binary and he may specify a wrong version such as And Conformance tests will fail when the version string is This patch is used to fail early in build steps, not in running the Conformance tests cases. Catch the issue early and fix it early. Another thing is, if users do not export the I want to avoid such cases at the very beginning of the build process, so users can fix it early. |
This seems reasonable, but I'm not an OWNER that can approve. |
hack/lib/version.sh
Outdated
@@ -96,6 +96,13 @@ kube::version::get_version_vars() { | |||
KUBE_GIT_MINOR+="+" | |||
fi | |||
fi | |||
|
|||
# If KUBE_GIT_VERSION is not a valid Semantic Version, then refuse to build. | |||
if ! [[ "${KUBE_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?([-][0-9A-Za-z.-]+|[-][0-9A-Za-z.-]+[+][0-9A-Za-z.-]+|[+][0-9A-Za-z.-]+)?$ ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: couldn't the last part of this be simplified to
(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?
?
i.e. "an optional pre-release version followed by an optional build metadata section"?
Full regex would look something like ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Thanks, this regx is better.
7d8aa4f
to
3b8b9e6
Compare
/lgtm unit test failure looks like a flake. cross failure is not you. |
/test pull-kubernetes-cross |
/test pull-kubernetes-e2e-kubeadm-gce-canary /test pull-kubernetes-cross |
tracking issue for crossbuild failure is #59121 |
/retest |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chenzhiwei, david-mcmahon, ixdy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these OWNERS Files:
Approvers can indicate their approval by writing |
/retest Review the full test history for this PR. Silence the bot with an |
/test pull-kubernetes-e2e-kubeadm-gce-canary |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
@chenzhiwei: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
What this PR does / why we need it:
Refuse to build Kubernetes when a version string like
v1.8.3+xx+xx
.This PR is to restrict the
KUBE_GIT_VERSION
, if the version string does match the rule of Semantic Version, then refuse to build.Since Kubernetes Conformance test needs the
KUBE_GIT_VERSION
to be a valid Semantic Version, so I think it's better to restrict the version string.Release note: