fix: compare Debian-style versions correctly and protect active sysext version#113
Merged
Conversation
…t version The version comparator passed Debian versions like "5+29.4.2-2~debian.13~trixie" to hashicorp/go-version, which treats everything after "+" as SemVer build metadata and excludes it from precedence. Every docker version collapsed to "5.0.0" and compared equal, so Vacuum (which runs after the symlink is created) could not distinguish new from old and its "keep newest N" deleted the freshly downloaded image, leaving a dangling docker.raw symlink. - version: route versions containing "~" or ":" to a dpkg-compatible comparator (epoch, then upstream, then revision; "~" sorts before everything). SemVer path is unchanged. - sysext: Vacuum now never removes the active (symlinked) version, regardless of sort order, as defense-in-depth against dangling links. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
docker.rawsysext symlink ended up dangling: it pointed atdocker_5+29.4.2-2~debian.13~trixie...but no such file existed on disk, so systemd-sysext could not merge the docker extension.Root cause
version.Comparepassed Debian-style versions like5+29.4.2-2~debian.13~trixietohashicorp/go-version, which treats everything after+as SemVer build metadata and excludes it from precedence comparison. Every docker version therefore collapsed to core5.0.0and compared equal.VacuumWithDetailsruns after the new symlink is created and keeps the newestInstancesMaxversions. With all versions comparing equal, the sort was a no-op and "keep newest N" deleted the freshly downloaded image (which sorted last lexically), leaving the dangling symlink.Fix
version/pattern.go— versions containing~or:are routed to a dpkg-compatible comparator (epoch → upstream → revision, with~sorting before everything, including end-of-string). The SemVer path is unchanged, so existing prerelease/v-prefix/date behavior is preserved.sysext/manager.go—VacuumWithDetailsnow never removes the active (symlinked) version regardless of sort order. Defense-in-depth that prevents a dangling symlink even if the comparator is wrong.Tests
TestCompare: Debian upstream/epoch/revision/tilde ordering, including the exact5+29.4.2-2~...vs5+29.3.1-1~...case.TestVacuumWithDetailsKeepsActiveSymlinkedVersion: reproduces the failure (symlink points at the oldest version) and asserts the active file is never deleted.Validation
Built the patched binary and ran it against the live repo: docker
29.5.2downloaded, symlink repaired, and the new image survived vacuum (it pruned the oldest29.3.0instead).docker --version→29.5.2, merged into/usr.🤖 Generated with Claude Code