Skip to content

Add upgrade-availability hint#2590

Draft
dgageot wants to merge 8 commits intodocker:mainfrom
dgageot:board/fix-for-docker-agent-issue-2467-35e2c81b
Draft

Add upgrade-availability hint#2590
dgageot wants to merge 8 commits intodocker:mainfrom
dgageot:board/fix-for-docker-agent-issue-2467-35e2c81b

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 29, 2026

Closes #2467.

Surfaces a hint when a newer GitHub release of docker-agent is available, in
both the TUI status bar and the `version` subcommand.

How it works

  • A new `pkg/version/check` package fetches the latest release tag from
    `https://api.github.com/repos/docker/docker-agent/releases/latest\` in a
    background goroutine and caches the result on disk for 24h
    (`/version-check.json`).
  • The fetch is triggered only by `docker agent run` / `--exec` (in
    `cmd/root/run.go`). All other subcommands and the TUI itself read the
    cache via `LatestCached` and never touch the network.
  • A dedicated `http.Client` is used (5s timeout, max 3 redirects) — never
    `http.DefaultClient`.
  • The cache is written atomically (write-temp + rename) so concurrent
    `docker agent run` processes can't corrupt it.
  • All errors (offline, rate-limited, parse errors, dev builds, …) are
    swallowed: the user simply does not see a hint.
  • A `dev` build never reports an upgrade.

Where the hint shows up

`docker agent version`:
```
docker agent version v1.0.0
Commit: abc123

A newer version is available: v1.53.0
Release notes: https://github.com/docker/docker-agent/releases/tag/v1.53.0
```

TUI status bar (right side of the title):
```
docker agent v1.0.0 (update available: v1.53.0)
```

Opt-out

Set `DOCKER_AGENT_DISABLE_VERSION_CHECK=1` (or `true`/`yes`/`on`)
to fully disable the feature — both the network call and the cached hint.
The env var is set unconditionally in the runtime stage of the Dockerfile,
since container images are immutable and can't self-upgrade.

The new env var is documented in `docs/configuration/overview/index.md`.

Tests

  • Unit tests for semver-tolerant comparison, cache I/O, GitHub fetch
    (via `httptest`), redirect-limit enforcement, opt-out env var, and the
    TUI title helper.
  • An exported `check.SeedCacheForTest` helper keeps the cache JSON layout
    encapsulated.
  • `go build ./...`, `go test ./...`, `go test -race`, and
    `golangci-lint run ./...` all pass.

dgageot added 8 commits April 29, 2026 08:13
Adds a best-effort GitHub-release check (cached for 24h, opt-out via DOCKER_AGENT_DISABLE_VERSION_CHECK=1) that surfaces an upgrade hint in the version subcommand and the TUI status bar.
Drop the unused synchronous Latest() function, replace the Result
struct with a plain LatestCached(current) string that returns "" when
no upgrade is known, and remove the redundant cache mutex and
write+rename dance — readCache already tolerates partial reads. Also
expose a SeedCacheForTest helper so external tests no longer reach
into the JSON layout.
- Use custom http.Client with 5s timeout instead of DefaultClient
- Limit redirects to 3 to prevent SSRF and redirect loops
- Add test for redirect limit enforcement
- Add test for concurrent RefreshAsync calls to verify thread safety
- Use errors.New instead of fmt.Errorf for static strings
- Use integer range loop (Go 1.22+)
- Fix formatting
Write to a temporary file and rename atomically to prevent cache
corruption when multiple docker agent processes run concurrently.
@dgageot dgageot requested a review from a team as a code owner April 29, 2026 09:18
@dgageot dgageot marked this pull request as draft April 29, 2026 09:20
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.

Add version check and upgrade notification

1 participant