Skip to content

[1.3] Embed version from VERSION file #4744

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

Merged
merged 2 commits into from
Apr 28, 2025

Conversation

kolyshkin
Copy link
Contributor

This is a backport of #4718 to release-1.3 branch. Original description follows.


This is a carry/rework of #3163.

See individual commits for details.

Aside from embedding VERSION file into the binary, it simplifies the output of runc help.

Before:

$ runc help
 ...
USAGE:
   runc [global options] command [command options] [arguments...]

VERSION:
   1.3.0-rc.1+dev
commit: v1.3.0-rc.1-93-g932e8342
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

COMMANDS:
   checkpoint  checkpoint a running container
...

After:

$ runc help
 ...
USAGE:
   runc [global options] command [command options] [arguments...]
   
VERSION:
   1.3.0-rc.1+dev

COMMANDS:
   checkpoint  checkpoint a running container
...

The full version info is still shown by runc --version exactly as before:

$ runc --version
runc version 1.3.0-rc.1+dev
commit: v1.3.0-rc.1-93-g932e8342
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

The EXTRA_VERSION kludge, added by #4370, also works exactly as before:

$ make EXTRA_VERSION="+build-1"
go build -trimpath "-buildmode=pie"  -tags "seccomp urfave_cli_no_docs" -ldflags "-X main.gitCommit=v1.3.0-rc.1-95-gd84aaa38 -X main.extraVersion=+build-1 " -o runc .
[kir@kir-tp1 runc]$ ./runc --version
runc version 1.3.0-rc.1+dev+build-1
commit: v1.3.0-rc.1-95-gd84aaa38
spec: 1.2.1
go: go1.24.2
libseccomp: 2.5.5

@kolyshkin kolyshkin added the backport/1.3-pr A backport PR to release-1.3 label Apr 23, 2025
@kolyshkin kolyshkin added this to the 1.3.0 milestone Apr 23, 2025
@kolyshkin kolyshkin changed the title [1.3] 4718 [1.3] Embed version from VERSION file Apr 23, 2025
Instead of setting cli.App.Version in main, let's set up
cli.VersionPrinter. This way, we only get various versions
when needed.

Note it does not change the output of runc --version.

It changes the output of runc --help though, and I think it's for the
better.

Before this patch:

> $ runc help
> ...
> USAGE:
>    runc [global options] command [command options] [arguments...]
>
> VERSION:
>    1.3.0-rc.1+dev
> commit: v1.3.0-rc.1-93-g932e8342
> spec: 1.2.1
> go: go1.24.2
> libseccomp: 2.5.5
>
> COMMANDS:
>    checkpoint  checkpoint a running container
> ...

After:

> $ runc help
> ...
> USAGE:
>    runc [global options] command [command options] [arguments...]
>
> VERSION:
>    1.3.0-rc.1+dev
>
> COMMANDS:
>    checkpoint  checkpoint a running container
> ...

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit d54eaaf)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This ensures that if runc is built without the provided Makefile, the
version is still properly set.

No change in the output.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit c12c99b)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@rata
Copy link
Member

rata commented Apr 24, 2025

What is the reason to apply this in 1.3? I understand we consider it not so risky, I'm not completely against this (although being so close to the release date, I think the risk is much higher), but why do we want this in 1.3?

@kolyshkin
Copy link
Contributor Author

What is the reason to apply this in 1.3? I understand we consider it not so risky, I'm not completely against this (although being so close to the release date, I think the risk is much higher), but why do we want this in 1.3?

Some builders (I've seen it once in moby if I'm not mistaken) don't use runc Makefile to build runc, and they use go build directly. When it's the case, version is not available, which may result in more troubles debugging the stuff.

With this change, version will always be available, so I consider it is an improvement worth having in v1.3, and the risk is low.

Copy link
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

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

LGTM. Since EXTRA_VERSION continues to work, I'm okay with this in 1.3.

@cyphar
Copy link
Member

cyphar commented Apr 28, 2025

@opencontainers/runc-maintainers Once we make a decision on this PR, I'll prepare the 1.3.0 release.

@cyphar cyphar requested a review from a team April 28, 2025 05:27
Copy link
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM

@rata rata merged commit 8d2e095 into opencontainers:release-1.3 Apr 28, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.3-pr A backport PR to release-1.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants