Skip to content

docker: parse suffixed Docker versions strictly - #3878

Open
Haihan-Jiang wants to merge 1 commit into
google:masterfrom
Haihan-Jiang:codex/cadvisor-docker-version-suffix-strict
Open

docker: parse suffixed Docker versions strictly#3878
Haihan-Jiang wants to merge 1 commit into
google:masterfrom
Haihan-Jiang:codex/cadvisor-docker-version-suffix-strict

Conversation

@Haihan-Jiang

Copy link
Copy Markdown

Fixes #3830. This is a replacement for the closed #3876 with the maintainer feedback addressed.

Docker server versions can be reported with a leading v and build/distribution suffixes such as v20.10.12-v1.0.2. cAdvisor currently parses Docker server versions with the generic unanchored VersionRe, which rejects that form because it finds multiple semantic-version substrings.

This change adds a Docker-specific server-version regexp that:

  • requires the version to start at the beginning of the string, with an optional v prefix;
  • captures the base major.minor.patch;
  • allows an optional suffix after the base version;
  • rejects arbitrary text such as random text 1.2.3 and also 9.9.9 build.

VersionRe remains unchanged for kernel-version parsing, so this does not broaden the older generic parser behavior.

Validation:

  • GOOS=linux go test -c ./container/docker -o /tmp/cadvisor-container-docker.test
  • go test ./container
  • git diff --check

Note: container/docker is Linux-only, so on macOS I compile-validated the Linux test binary instead of executing it locally.

@Haihan-Jiang

Copy link
Copy Markdown
Author

This is ready for review. The Docker version parser now handles suffixed versions strictly, with tests around the factory version gating. The visible checks are green.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 90 days with no activity. This PR will be closed in 30 days unless new comments are made or the stale label is removed. To skip these checks, apply the "lifecycle/frozen" label.

@github-actions github-actions Bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container metadata labels lost when Docker version contains multiple suffixes

1 participant