Skip to content

Commit ff191c5

Browse files
committed
api: info: deprecate "Commit.Expected" fields
The `Commit` type was introduced in 2790ac6, to assist triaging issues that were reported with an incorrect version of runc or containerd. At the time, both `runc` and `containerd` were not yet stable, and had to be built from a specific commit to guarantee compatibility. We encountered various situations where unexpected (and incompatible) versions of those binaries were packaged, resulting in hard to trace bug-reports. For those situations, a "expected" version was set at compile time, to indicate if the version installed was different from the expected version; docker info ... runc version: a592beb5bc4c4092b1b1bac971afed27687340c5 (expected: 69663f0bd4b60df09991c08812a60108003fa340) Both `runc` and `containerd` are stable now, and docker 19.03 and up set the expected version to the actual version since c65f0bd and 23.0 did the same for the `init` binary b585c64, to prevent the CLI from reporting "unexpected version". In short; the `Expected` fields no longer serves a real purpose. In future, we can even consider deprecating the `ContainerdCommit`, `RuncCommit` and `InitCommit` fields on the `/info` response (as we also include this information as part of the components returned in `/version`), but those can still be useful currently for situations where a user only provides `docker info` output. This patch starts with deprecating the `Expected` field. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 164cae5 commit ff191c5

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

api/server/router/system/system_routes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
100100
// Containerd field introduced in API v1.46.
101101
info.Containerd = nil
102102
}
103+
104+
// TODO(thaJeztah): Expected commits are deprecated, and should no longer be set in API 1.49.
105+
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
106+
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
107+
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
108+
103109
if versions.GreaterThanOrEqualTo(version, "1.42") {
104110
info.KernelMemory = false
105111
}

api/swagger.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6170,6 +6170,8 @@ definitions:
61706170
Expected:
61716171
description: |
61726172
Commit ID of external tool expected by dockerd as set at build time.
6173+
6174+
**Deprecated**: This field is deprecated and will be omitted in a API v1.49.
61736175
type: "string"
61746176
example: "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
61756177

api/types/system/info.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,13 @@ type PluginsInfo struct {
137137
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
138138
// in the version-string of external tools, such as containerd, or runC.
139139
type Commit struct {
140-
ID string // ID is the actual commit ID of external tool.
141-
Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time.
140+
// ID is the actual commit ID or version of external tool.
141+
ID string
142+
143+
// Expected is the commit ID of external tool expected by dockerd as set at build time.
144+
//
145+
// Deprecated: this field is no longer used in API v1.49, but kept for backward-compatibility with older API versions.
146+
Expected string
142147
}
143148

144149
// NetworkAddressPool is a temp struct used by [Info] struct.

daemon/info_unix.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ func populateRuncCommit(v *system.Commit, cfg *configStore) error {
196196
return err
197197
}
198198
v.ID = commit
199-
v.Expected = commit
200199
return nil
201200
}
202201

@@ -223,7 +222,6 @@ func (daemon *Daemon) populateInitCommit(ctx context.Context, v *system.Info, cf
223222
return nil
224223
}
225224
v.InitCommit.ID = commit
226-
v.InitCommit.Expected = v.InitCommit.ID
227225
return nil
228226
}
229227

@@ -437,7 +435,6 @@ func (daemon *Daemon) populateContainerdCommit(ctx context.Context, v *system.Co
437435
return nil
438436
}
439437
v.ID = rv.Revision
440-
v.Expected = rv.Revision
441438
return nil
442439
}
443440

docs/api/version-history.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ keywords: "API, Docker, rcli, REST, documentation"
2424
`platform` parameter (JSON encoded OCI Platform type) that allows to specify
2525
a platform to load/save. Not passing this parameter will result in
2626
loading/saving the full multi-platform image.
27+
* Deprecated: The `ContainerdCommit.Expected`, `RuncCommit.Expected`, and
28+
`InitCommit.Expected` fields in the `GET /info` endpoint are deprecated
29+
and will be omitted in API v1.49.
2730

2831
## v1.47 API changes
2932

integration/system/info_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func TestInfoBinaryCommits(t *testing.T) {
1717
assert.NilError(t, err)
1818

1919
assert.Check(t, "N/A" != info.ContainerdCommit.ID)
20-
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID))
20+
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
2121

2222
assert.Check(t, "N/A" != info.InitCommit.ID)
23-
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID))
23+
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
2424

2525
assert.Check(t, "N/A" != info.RuncCommit.ID)
26-
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID))
26+
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID)) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
2727
}

0 commit comments

Comments
 (0)