Skip to content

Commit 25fbe6c

Browse files
authored
Merge pull request moby#51725 from robmry/max-api-1.53
Update client MaxAPIVersion to 1.53
2 parents ec136d7 + 54a6ec3 commit 25fbe6c

File tree

7 files changed

+31
-17
lines changed

7 files changed

+31
-17
lines changed

api/docs/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ keywords: "API, Docker, rcli, REST, documentation"
3333
* Deprecated: the Engine was automatically backfilling empty `PortBindings` lists with
3434
a PortBinding with an empty HostIP and HostPort when calling `POST /containers/{id}/start`.
3535
This behavior is now deprecated, and a warning is returned by `POST /containers/create`.
36-
The next API version will drop empty `PortBindings` list altogether.
36+
A future API version will drop empty `PortBindings` list altogether.
3737
* `GET /images/{name}/json` now omits the following `Config` fields when
3838
not set, to closer align with the implementation of the [OCI Image Specification](https://github.com/opencontainers/image-spec/blob/v1.1.1/specs-go/v1/config.go#L23-L62)
3939
`Cmd`, `Entrypoint`, `Env`, `Labels`, `OnBuild`, `User`, `Volumes`, and `WorkingDir`.

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const DummyHost = "api.moby.localhost"
106106
// overriding the version and disable API-version negotiation.
107107
//
108108
// This version may be lower than the version of the api library module used.
109-
const MaxAPIVersion = "1.52"
109+
const MaxAPIVersion = "1.53"
110110

111111
// MinAPIVersion is the minimum API version supported by the client. API versions
112112
// below this version are not considered when performing API-version negotiation.

daemon/server/router/container/container_routes.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -903,26 +903,33 @@ func handlePortBindingsBC(hostConfig *container.HostConfig, version string) stri
903903
if len(bindings) > 0 {
904904
continue
905905
}
906-
if versions.GreaterThan(version, "1.52") && len(bindings) == 0 {
907-
// Starting with API 1.53, no backfilling is done. An empty slice
908-
// of port bindings is treated as "no port bindings" by the daemon,
909-
// but it still needs to backfill empty slices when loading the
910-
// on-disk state for containers created by older versions of the
911-
// Engine. Drop the PortBindings entry to ensure that no backfilling
912-
// will happen when restarting the daemon.
913-
delete(hostConfig.PortBindings, port)
914-
continue
915-
}
906+
/*
907+
API 1.53 shipped in a minor release. We cannot introduce a breaking change there, so
908+
we must still backfill empty port bindings. This change can be re-introduced for the
909+
API version that ships in 30.x. Note that some networking tests will need fixing.
910+
See https://github.com/moby/moby/issues/51727
911+
912+
if versions.GreaterThan(version, "1.52") && len(bindings) == 0 {
913+
// Starting with API 1.53, no backfilling is done. An empty slice
914+
// of port bindings is treated as "no port bindings" by the daemon,
915+
// but it still needs to backfill empty slices when loading the
916+
// on-disk state for containers created by older versions of the
917+
// Engine. Drop the PortBindings entry to ensure that no backfilling
918+
// will happen when restarting the daemon.
919+
delete(hostConfig.PortBindings, port)
920+
continue
921+
}
922+
*/
916923

917-
if versions.Equal(version, "1.52") {
924+
if versions.GreaterThanOrEqualTo(version, "1.52") {
918925
emptyPBs = append(emptyPBs, port.String())
919926
}
920927

921928
hostConfig.PortBindings[port] = []network.PortBinding{{}}
922929
}
923930

924931
if len(emptyPBs) > 0 {
925-
return fmt.Sprintf("Following container port(s) have an empty list of port-bindings: %s. Starting with API 1.53, such bindings will be discarded.", strings.Join(emptyPBs, ", "))
932+
return fmt.Sprintf("Following container port(s) have an empty list of port-bindings: %s. Such bindings will be discarded in a future version.", strings.Join(emptyPBs, ", "))
926933
}
927934

928935
return ""

integration/network/bridge/bridge_linux_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ func TestPortMappingRestore(t *testing.T) {
789789
const svrName = "svr"
790790
cid := ctr.Run(ctx, t, c,
791791
ctr.WithExposedPorts("80/tcp"),
792+
// TODO(robmry): this test supplies an empty list of PortBindings.
793+
// https://github.com/moby/moby/issues/51727 will break it.
792794
ctr.WithPortMap(networktypes.PortMap{networktypes.MustParsePort("80/tcp"): {}}),
793795
ctr.WithName(svrName),
794796
ctr.WithRestartPolicy(containertypes.RestartPolicyUnlessStopped),
@@ -996,7 +998,7 @@ func TestEmptyPortBindingsBC(t *testing.T) {
996998
{}, // An empty PortBinding is backfilled
997999
}}
9981000
expWarnings := []string{
999-
"Following container port(s) have an empty list of port-bindings: 80/tcp. Starting with API 1.53, such bindings will be discarded.",
1001+
"Following container port(s) have an empty list of port-bindings: 80/tcp. Such bindings will be discarded in a future version.",
10001002
}
10011003

10021004
mappings, warnings := createInspect(t, "1.52", []networktypes.PortBinding{})
@@ -1005,6 +1007,7 @@ func TestEmptyPortBindingsBC(t *testing.T) {
10051007
})
10061008

10071009
t.Run("no backfilling on API 1.53", func(t *testing.T) {
1010+
t.Skip("Backfilling was not removed in 1.53. See https://github.com/moby/moby/issues/51727")
10081011
expMappings := networktypes.PortMap{}
10091012
expWarnings := make([]string, 0)
10101013

integration/networking/bridge_linux_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ func TestBridgeINCRouted(t *testing.T) {
389389
container.WithNetworkMode(netName),
390390
container.WithName("ctr-"+gwMode),
391391
container.WithExposedPorts("80/tcp"),
392+
// TODO(robmry): this test supplies an empty list of PortBindings.
393+
// https://github.com/moby/moby/issues/51727 will break it.
392394
container.WithPortMap(networktypes.PortMap{networktypes.MustParsePort("80/tcp"): {}}),
393395
)
394396
t.Cleanup(func() {

integration/networking/port_mapping_linux_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,9 @@ func TestDirectRoutingOpenPorts(t *testing.T) {
706706
container.WithName("ctr-"+gwMode),
707707
container.WithExposedPorts("80/tcp"),
708708
container.WithPortMap(networktypes.PortMap{
709-
networktypes.MustParsePort("80/tcp"): {},
709+
// TODO(robmry): this test supplies an empty list of PortBindings.
710+
// https://github.com/moby/moby/issues/51727 will break it.
711+
networktypes.MustParsePort("80/tcp"): {{}},
710712
}),
711713
)
712714
t.Cleanup(func() {

vendor/github.com/moby/moby/client/client.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)