Skip to content

Commit

Permalink
Merge pull request moby#48478 from thaJeztah/deprecate_info_expected_…
Browse files Browse the repository at this point in the history
…version

api: info: deprecate "Commit.Expected" fields
  • Loading branch information
tianon authored Sep 30, 2024
2 parents 34950b5 + ff191c5 commit b5d04e4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions api/server/router/system/system_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
// Containerd field introduced in API v1.46.
info.Containerd = nil
}

// TODO(thaJeztah): Expected commits are deprecated, and should no longer be set in API 1.49.
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.

if versions.GreaterThanOrEqualTo(version, "1.42") {
info.KernelMemory = false
}
Expand Down
2 changes: 2 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6170,6 +6170,8 @@ definitions:
Expected:
description: |
Commit ID of external tool expected by dockerd as set at build time.
**Deprecated**: This field is deprecated and will be omitted in a API v1.49.
type: "string"
example: "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"

Expand Down
9 changes: 7 additions & 2 deletions api/types/system/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ type PluginsInfo struct {
// Commit holds the Git-commit (SHA1) that a binary was built from, as reported
// in the version-string of external tools, such as containerd, or runC.
type Commit struct {
ID string // ID is the actual commit ID of external tool.
Expected string // Expected is the commit ID of external tool expected by dockerd as set at build time.
// ID is the actual commit ID or version of external tool.
ID string

// Expected is the commit ID of external tool expected by dockerd as set at build time.
//
// Deprecated: this field is no longer used in API v1.49, but kept for backward-compatibility with older API versions.
Expected string
}

// NetworkAddressPool is a temp struct used by [Info] struct.
Expand Down
3 changes: 0 additions & 3 deletions daemon/info_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func populateRuncCommit(v *system.Commit, cfg *configStore) error {
return err
}
v.ID = commit
v.Expected = commit
return nil
}

Expand All @@ -223,7 +222,6 @@ func (daemon *Daemon) populateInitCommit(ctx context.Context, v *system.Info, cf
return nil
}
v.InitCommit.ID = commit
v.InitCommit.Expected = v.InitCommit.ID
return nil
}

Expand Down Expand Up @@ -437,7 +435,6 @@ func (daemon *Daemon) populateContainerdCommit(ctx context.Context, v *system.Co
return nil
}
v.ID = rv.Revision
v.Expected = rv.Revision
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions docs/api/version-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ keywords: "API, Docker, rcli, REST, documentation"
`platform` parameter (JSON encoded OCI Platform type) that allows to specify
a platform to load/save. Not passing this parameter will result in
loading/saving the full multi-platform image.
* Deprecated: The `ContainerdCommit.Expected`, `RuncCommit.Expected`, and
`InitCommit.Expected` fields in the `GET /info` endpoint are deprecated
and will be omitted in API v1.49.

## v1.47 API changes

Expand Down
6 changes: 3 additions & 3 deletions integration/system/info_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func TestInfoBinaryCommits(t *testing.T) {
assert.NilError(t, err)

assert.Check(t, "N/A" != info.ContainerdCommit.ID)
assert.Check(t, is.Equal(info.ContainerdCommit.Expected, info.ContainerdCommit.ID))
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.

assert.Check(t, "N/A" != info.InitCommit.ID)
assert.Check(t, is.Equal(info.InitCommit.Expected, info.InitCommit.ID))
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.

assert.Check(t, "N/A" != info.RuncCommit.ID)
assert.Check(t, is.Equal(info.RuncCommit.Expected, info.RuncCommit.ID))
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.
}

0 comments on commit b5d04e4

Please sign in to comment.