Skip to content

fix sending v prefixed semver version to older etcd peer versions that use the coreos/go-semver - #22261

Open
upodroid wants to merge 1 commit into
etcd-io:mainfrom
upodroid:fix-semver-prefix
Open

fix sending v prefixed semver version to older etcd peer versions that use the coreos/go-semver#22261
upodroid wants to merge 1 commit into
etcd-io:mainfrom
upodroid:fix-semver-prefix

Conversation

@upodroid

@upodroid upodroid commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

In #20915, we are building etcd with Version that is prefixed with v.

Sending, for example, v2.1.0 in the X-Server-Version header will cause semver parsing errors, so the v needs to be stripped. This code can be removed from 3.9 onwards.

…t use the coreos/go-semver

Signed-off-by: upodroid <cy@borg.dev>
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: upodroid
Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow

Copy link
Copy Markdown

Hi @upodroid. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

Comment thread api/version/version.go
Comment on lines +91 to +101

// VersionForPeer returns the version string to use in the X-Server-Version header
// when communicating with a peer. Peers older than v3.8 use github.com/coreos/go-semver
// which does not accept a leading "v" prefix and will panic when parsing it.
// If the peer version is unknown (nil) or less than v3.8, the "v" prefix is stripped.
func VersionForPeer(peerVer *semver.Version) string {
if peerVer == nil || peerVer.LessThan(&V3_8) {
return strings.TrimPrefix(Version, "v")
}
return Version
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the behavior that we want starting 3.8, though? Or should we always keep the version without the "v" prefix?

I think updating to a new semver library makes sense, but I'm not so sure about changing the API behavior.

cc. @ahrtr, @serathius

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we always keep the version without the "v" prefix?

+1

@ahrtr ahrtr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the API between peers without a strong justification.

@upodroid

Copy link
Copy Markdown
Contributor Author

Please don't change the API between peers without a strong justification.

Here is the plan:

  1. Add the new semver library to 3.8
  2. Merge this shim code for 3.8
  3. Release 3.8.x where the version string DOESN'T start with v, but if you do a custom build where it does start with v, it works.
  4. Delete this shim code for 3.9 because 3.8 peers can handle v-prefixed peers
  5. Announce a breaking change in 3.9 where the version string DOES start with v. This would only be a breaking change if you are getting versions via metrics or etcdctl --version, etc. The internals of etcd work without any breaking changes.
  6. Cleanup the CI/Release scripts

The main justification is that you simplify the release process and eliminate the need to commit versions after cutting tags. You can cut the tag, read the tag value and build it. Also, it will enable testing nightly builds like these: v3.8.0-alpha.0-243-gab92bd755f080a.

 mahamed  Mac  ~  1  $  curl https://dl.k8s.io/ci/latest.txt
v1.38.0-alpha.0.15+a231bf3f37761e

@ahrtr

ahrtr commented Aug 15, 2026

Copy link
Copy Markdown
Member

3. Release 3.8.x where the version string DOESN'T start with v

I am not against this.

3. but if you do a custom build where it does start with v, it works.

Never do this to avoid unnecessary toil on migration, doc stuff.

@ivanvc

ivanvc commented Aug 19, 2026

Copy link
Copy Markdown
Member

This may be a naive question, but what's the issue with always returning the following?

return strings.TrimPrefix(Version, "v")

So we don't add a breaking change.

@upodroid

Copy link
Copy Markdown
Contributor Author

I'll explain it more at the community meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants