feat: show RootlessKit version in nerdctl version output#4971
Conversation
98761a9 to
02bf394
Compare
| return &dockercompat.ComponentVersion{ | ||
| Name: "rootlesskit", | ||
| Version: fields[2], | ||
| }, nil |
| // getMobySysInfo returns the moby system info for the given cgroup manager | ||
|
|
||
| func rootlessKitVersion() dockercompat.ComponentVersion { | ||
| stdout, err := exec.Command("rootlesskit", "--version").Output() |
|
There was already a PR #4937 from @MD-Mushfiqur123 , but it seems accidentally closed. |
02bf394 to
16aaa26
Compare
|
Thanks @AkihiroSuda for the review. I've reworked the implementation per your feedback:
The function is still only called when Regarding PR #4937 from @MD-Mushfiqur123 — I saw it was accidentally closed. Happy to step aside if they'd like to re-open theirs, or keep this one going if that's simpler for you. |
16aaa26 to
dd8e035
Compare
| } | ||
| return dockercompat.ComponentVersion{ | ||
| Name: "rootlesskit", | ||
| Version: info.Version, |
There was a problem hiding this comment.
As in Docker, it should also expose ApiVersion, NetworkDriver, etc.
#4971 (comment)
Please confirm that the output format corresponds to Docker.
dd8e035 to
120deb8
Compare
|
Done — added |
| log.L.WithError(err).Warnf("unable to retrieve RootlessKit version via API") | ||
| return dockercompat.ComponentVersion{Name: "rootlesskit"} | ||
| } | ||
| details := map[string]string{ |
When running in rootless mode, nerdctl version now includes the RootlessKit version as a server component, matching the format used by docker version. The version is retrieved via the RootlessKit API socket (rootlessutil.NewRootlessKitClient + Info(ctx)) rather than shelling out to rootlesskit --version, which is more robust and avoids PATH issues. The version is only shown when rootless mode is active (i.e. when rootlessutil.IsRootless() is true). If the API socket is unavailable or the Info call fails, a warning is logged and the component is shown without a version string. Fixes containerd#4936 Signed-off-by: Aaron Mark <64331623+amarkdotdev@users.noreply.github.com>
120deb8 to
1e8a519
Compare
|
Added |
Description
When running in rootless mode,
nerdctl versionnow includes the RootlessKit version as a server component, matching howdocker versiondisplays it.Before:
After (rootless mode):
The
rootlesskitcomponent is only shown whenrootlessutil.IsRootless()is true. Ifrootlesskitis not found on PATH or its output cannot be parsed, a warning is logged and the component appears without a version string (same pattern asruncandbuildctl).Changes
pkg/infoutil/infoutil.go: addedrootlessKitVersion()andparseRootlessKitVersion()functions, appended toServerVersion.Componentswhen rootlesspkg/infoutil/infoutil_test.go: addedTestParseRootlessKitVersioncovering normal output, dev versions, and invalid inputTesting
go build ./pkg/infoutil/...passesgo vet ./pkg/infoutil/...passesgo test ./pkg/infoutil/...passes (including the new parse test)Fixes #4936