Skip to content

Make Docker API version configurable#55

Merged
umputun merged 2 commits intomasterfrom
configurable-docker-api-version
Apr 14, 2026
Merged

Make Docker API version configurable#55
umputun merged 2 commits intomasterfrom
configurable-docker-api-version

Conversation

@umputun
Copy link
Copy Markdown
Owner

@umputun umputun commented Apr 14, 2026

The Docker provider hardcodes API version 1.24 (Docker Engine 1.12 era). Newer Docker engines (28+, e.g. on Ubuntu 24.04) dropped support for API versions below 1.44, causing sys-agent to fail with "client version 1.24 is too old" when querying /v1.24/containers/json.

Changes:

  • Replace hardcoded dockerClientVersion constant with configurable APIVersion field on DockerProvider
  • Add --docker-api CLI flag / DOCKER_API env var (default 1.24)
  • Wire the option from CLI through to the provider
  • Add defer ts.Close() to all Docker test httptest servers
  • Document the new option in README (usage block, parameters, docker-compose example)

Replace hardcoded dockerClientVersion constant with configurable
APIVersion field on DockerProvider. Adds --docker-api CLI flag and
DOCKER_API env var (default "1.24") to support newer Docker engines
that dropped old API versions (e.g., Docker 28+ requires 1.44+).
Copilot AI review requested due to automatic review settings April 14, 2026 07:09
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 14, 2026

Coverage Report for CI Build 24386129258

Coverage increased (+0.05%) to 86.756%

Details

  • Coverage increased (+0.05%) from the base build.
  • Patch coverage: 6 of 6 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1125
Covered Lines: 976
Line Coverage: 86.76%
Coverage Strength: 4.87 hits per line

💛 - Coveralls

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the Docker Engine API version used by the Docker status provider configurable to avoid failures on newer Docker engines that no longer support the previously hardcoded API version.

Changes:

  • Replace the hardcoded Docker API version with an APIVersion field on DockerProvider (defaulting to 1.24 when unset).
  • Add --docker-api / DOCKER_API and wire it through main into the Docker provider.
  • Update Docker provider tests to cover both custom and default API versions, and ensure all httptest servers are closed; document the new option in the README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
app/status/external/docker_provider.go Adds configurable API version handling (with a default when unset) to the Docker provider request path.
app/status/external/docker_provider_test.go Updates tests to assert the configured API version is used and adds coverage for the default behavior; closes test servers.
app/main.go Introduces --docker-api / DOCKER_API flag and wires the value into the Docker provider.
README.md Documents the new CLI/env option and provides guidance for newer Docker engines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/main.go
Comment on lines +35 to +37
Concurrency int `long:"concurrency" env:"CONCURRENCY" default:"4" description:"number of concurrent requests to services"`
DockerAPIVersion string `long:"docker-api" env:"DOCKER_API" default:"1.24" description:"docker API version"`
Dbg bool `long:"dbg" env:"DEBUG" description:"show debug info"`
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

The CLI flag --docker-api accepts an arbitrary string and is only validated indirectly when the Docker request is built. To fail fast with a helpful message, consider validating opts.DockerAPIVersion after parsing (e.g., require major.minor format) and exiting with a clear error if invalid.

Copilot uses AI. Check for mistakes.
Comment thread README.md Outdated
--concurrency= number of concurrent requests to services (default: 4) [$CONCURRENCY]
--timeout= timeout for each request to services (default: 5s) [$TIMEOUT]
--timeout= timeout for each request to services (default: 5s) [$TIMEOUT]
--docker-api= docker API version (default: 1.24) [$DOCKER_API]
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

In the usage block, the --docker-api line has an extra space after = compared to the surrounding options. This looks like a formatting typo and makes the documented help output inconsistent; please align the spacing with the other lines.

Suggested change
--docker-api= docker API version (default: 1.24) [$DOCKER_API]
--docker-api= docker API version (default: 1.24) [$DOCKER_API]

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +54
apiVersion := d.APIVersion
if apiVersion == "" {
apiVersion = "1.24"
}
dkURL := fmt.Sprintf("http://localhost/v%s/containers/json", apiVersion)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

APIVersion is user-configurable (CLI/env) but is interpolated directly into the request path. This allows invalid values (spaces, '/', '?', etc.) to produce malformed URLs or unexpected Docker endpoints and yields a generic request error. Consider normalizing (trim spaces, optionally strip leading 'v') and validating the version format (e.g., ^\d+\.\d+$) and returning a clear error when invalid.

Copilot uses AI. Check for mistakes.
@umputun umputun merged commit 4d5253f into master Apr 14, 2026
9 checks passed
@umputun umputun deleted the configurable-docker-api-version branch April 14, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants