Skip to content

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jan 22, 2024

api: remove deprecated API versions (API < v1.24)

api: remove deprecated API versions (API v1.23 and before)

related:

runconfig: remove fixtures for api < v1.19

api: POST /commit: remove version-gate for "pause" (api < v1.16)

The "pause" flag was added in API v1.13 (Docker Engine v1.1.0), and is
enabled by default (see 17d870b).

API v1.23 and older are deprecated, so we can remove the version-gate.

api: POST /build: remove version-gate for "rm", "force-rm" (api < v1.16)

The "rm" option was made the default in API v1.12 (Docker Engine v1.0.0)
in commit b60d647, and "force-rm" was
added in 667e2bd.

API v1.23 and older are deprecated, so we can remove these gates.

api: POST /build: remove version-gate for "pull" (api < v1.16)

The "pull" option was added in API v1.16 (Docker Engine v1.4.0) in commit
054e57a, which gated the option by API
version.

API v1.23 and older are deprecated, so we can remove the gate.

api: remove code for adjusting CPU shares (api < v1.19)

API versions before 1.19 allowed CpuShares that were greater than the maximum
or less than the minimum supported by the kernel, and relied on the kernel to
do the right thing.

Commit ed39fbe introduced code to adjust the
CPU shares to be within the accepted range when using API version 1.18 or
lower.

API v1.23 and older are deprecated, so we can remove support for this
functionality.

Currently, there's no validation for CPU shares to be within an acceptable
range; a TODO was added to add validation for this option, and to use the
linuxMinCPUShares and linuxMaxCPUShares consts for this.

api: POST /containers/{id}/kill: remove handling for api < 1.20

API v1.20 and up produces an error when signalling / killing a non-running
container (see c92377e). Older API versions
allowed this, and an exception was added in 621e3d8.

API v1.23 and older are deprecated, so we can remove this handling.

api: remove code for ContainerInspect on api < v1.20

API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.19 and lower.

api: remove code for ContainerInspect on api v1.20

API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.20.

api: remove code for container stats on api < v1.21

API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.20 and lower.

api: update test to reflect reality on Windows

The TestInspectAPIContainerResponse mentioned that Windows does not
support API versions before v1.25.

While technically, no stable release existed for Windows with API versions
before that (see f811d5b), API version
v1.24 was enabled in e4af39a, to have
a consistend fallback version for API version negotiation.

This patch updates the test to reflect that change.

api: POST /exec/{id}/start: remove support for API < v1.21

API v1.21 (Docker Engine v1.9.0) enforces the request to have a JSON
content-type on exec start (see 45dc57f).
An exception was added in 0b5e628 to
make this check conditional (supporting API < 1.21).

API v1.23 and older are deprecated, and this patch removes the feature.

api: remove POST /containers/{id}/copy endpoint (api < v1.23)

This endpoint was deprecated in API v1.20 (Docker Engine v1.8.0) in
commit db9cc91, in favor of the
PUT /containers/{id}/archive and HEAD /containers/{id}/archive
endpoints, and disabled in API v1.24 (Docker Engine v1.12.0) through
commit 4283289.

This patch removes the endpoint, and the associated daemon.ContainerCopy
method in the backend.

api: remove plain-text error-responses (api < v1.24)

Commit 322e2a7 changed the format of errors
returned by the API to be in JSON format for API v1.24. Older versions of
the API returned errors in plain-text format.

API v1.23 and older are deprecated, so we can remove support for plain-text
error responses.

api: remove handling of HostConfig on POST /containers/{id}/start (api < v1.24)

API v1.20 (Docker Engine v1.11.0) and older allowed a HostConfig to be passed
when starting a container. This feature was deprecated in API v1.21 (Docker
Engine v1.10.0) in 3e7405a, and removed in
API v1.23 (Docker Engine v1.12.0) in commit 0a8386c.

API v1.23 and older are deprecated, and this patch removes the feature.

api: remove API < v1.24

Commit 08e4e88 (Docker Engine v25.0.0)
deprecated API version v1.23 and lower, but older API versions could be
enabled through the DOCKER_MIN_API_VERSION environment variable.

This patch removes all support for API versions < v1.24.

api: add MinSupportedAPIVersion const

This const contains the minimum API version that can be supported by the
API server. The daemon is currently configured to use the same version,
but we may increment the configured minimum version when deprecating
old API versions in future.

api/server/middleware: VersionMiddleware: improve docs

Improve documentation and rename fields and variables to be more descriptive.

api/server/middleware:use API-consts in tests

Use the API consts to have more realistic values in tests.

api/server/middleware: NewVersionMiddleware: add validation

Make sure the middleware cannot be initialized with out of range versions.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Member Author

Whoop! All green ✅🥳

@thaJeztah thaJeztah force-pushed the remove_deprecated_api_versions branch 3 times, most recently from 0b83e77 to b3a79de Compare January 22, 2024 18:38
@thaJeztah thaJeztah marked this pull request as ready for review January 22, 2024 19:55
@thaJeztah thaJeztah requested review from corhere, cpuguy83 and vvoland and removed request for tianon and tonistiigi January 22, 2024 19:55
Comment on lines +29 to 33
// FIXME (thaJeztah): update fixtures for more current versions.
if runtime.GOOS != "windows" {
imgName = "ubuntu"
fixtures = []f{
{"fixtures/unix/container_config_1_14.json", strslice.StrSlice{}},
{"fixtures/unix/container_config_1_17.json", strslice.StrSlice{"bash"}},
{"fixtures/unix/container_config_1_19.json", strslice.StrSlice{"bash"}},
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like we don't have fixtures for more current configs; we should create some 😅

@thaJeztah thaJeztah force-pushed the remove_deprecated_api_versions branch 3 times, most recently from 96f18c1 to ec9aded Compare January 30, 2024 13:40
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The "pause" flag was added in API v1.13 (Docker Engine v1.1.0), and is
enabled by default (see 17d870b).

API v1.23 and older are deprecated, so we can remove the version-gate.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The "rm" option was made the default in API v1.12 (Docker Engine v1.0.0)
in commit b60d647, and "force-rm" was
added in 667e2bd.

API v1.23 and older are deprecated, so we can remove these gates.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The "pull" option was added in API v1.16 (Docker Engine v1.4.0) in commit
054e57a, which gated the option by API
version.

API v1.23 and older are deprecated, so we can remove the gate.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API versions before 1.19 allowed CpuShares that were greater than the maximum
or less than the minimum supported by the kernel, and relied on the kernel to
do the right thing.

Commit ed39fbe introduced code to adjust the
CPU shares to be within the accepted range when using API version 1.18 or
lower.

API v1.23 and older are deprecated, so we can remove support for this
functionality.

Currently, there's no validation for CPU shares to be within an acceptable
range; a TODO was added to add validation for this option, and to use the
`linuxMinCPUShares` and `linuxMaxCPUShares` consts for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API v1.20 and up produces an error when signalling / killing a non-running
container (see c92377e). Older API versions
allowed this, and an exception was added in 621e3d8.

API v1.23 and older are deprecated, so we can remove this handling.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.19 and lower.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.20.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The TestInspectAPIContainerResponse mentioned that Windows does not
support API versions before v1.25.

While technically, no stable release existed for Windows with API versions
before that (see f811d5b), API version
v1.24 was enabled in e4af39a, to have
a consistend fallback version for API version negotiation.

This patch updates the test to reflect that change.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API v1.23 and older are deprecated, so we can remove the code to adjust
responses for API v1.20 and lower.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
API v1.21 (Docker Engine v1.9.0) enforces the request to have a JSON
content-type on exec start (see 45dc57f).
An exception was added in 0b5e628 to
make this check conditional (supporting API < 1.21).

API v1.23 and older are deprecated, and this patch removes the feature.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This endpoint was deprecated in API v1.20 (Docker Engine v1.8.0) in
commit db9cc91, in favor of the
`PUT /containers/{id}/archive` and `HEAD /containers/{id}/archive`
endpoints, and disabled in API v1.24 (Docker Engine v1.12.0) through
commit 4283289.

This patch removes the endpoint, and the associated `daemon.ContainerCopy`
method in the backend.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Commit 322e2a7 changed the format of errors
returned by the API to be in JSON format for API v1.24. Older versions of
the API returned errors in plain-text format.

API v1.23 and older are deprecated, so we can remove support for plain-text
error responses.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…i < v1.24)

API v1.20 (Docker Engine v1.11.0) and older allowed a HostConfig to be passed
when starting a container. This feature was deprecated in API v1.21 (Docker
Engine v1.10.0) in 3e7405a, and removed in
API v1.23 (Docker Engine v1.12.0) in commit 0a8386c.

API v1.23 and older are deprecated, and this patch removes the feature.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Commit 08e4e88 (Docker Engine v25.0.0)
deprecated API version v1.23 and lower, but older API versions could be
enabled through the DOCKER_MIN_API_VERSION environment variable.

This patch removes all support for API versions < v1.24.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This const contains the minimum API version that can be supported by the
API server. The daemon is currently configured to use the same version,
but we may increment the _configured_ minimum version when deprecating
old API versions in future.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Improve documentation and rename fields and variables to be more descriptive.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use the API consts to have more realistic values in tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Make sure the middleware cannot be initialized with out of range versions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the remove_deprecated_api_versions branch from 712e731 to 14503cc Compare February 6, 2024 17:44
@thaJeztah
Copy link
Member Author

done 👍

@thaJeztah thaJeztah merged commit 9e075f3 into moby:master Feb 7, 2024
@thaJeztah thaJeztah deleted the remove_deprecated_api_versions branch February 7, 2024 00:43
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Jun 16, 2024
The runconfig package contained compatibility code to unmarshal API
requests on API < v1.18, and to convert them to current API versions.
These fields were marked as deprecated, but didn't mention relevant API
versions, so some digging was needed to track back history;

API versions before 1.18 accepted top-level `Memory`, `MemorySwap`,
`CpuShares`, and `Cpuset` fields as part of the container create requests.
These fields were not considered "portable", and therefore moved to the
`HostConfig` struct in 837eec0. The
API version at that time was [v1.18]. For backward-compatibility, the
existing top-level fields were kept, and conversion code was added in
[ContainerHostConfigFromJob] to copy their values to `HostConfig` if
present.

A refactor in 767df67 introduced a new
`ContainerConfigWrapper` struct, which embedded the container-config and
a (non-exported) `hostConfigWrapper`. This resulted in an incompatibility
when compiling with gccgo, sn eb97de7
removed the non-exported `hostConfigWrapper`, instead embedding the
`HostConfig` and adding a `CpuSet` field. The API version at that time
was [v1.19].

With the introduction of Windows containers, which did not need conversion
code as it never supported previous API versions, the `ContainerConfigWrapper`
was split to Linux and Windows implementation in f6ed590.
This change introduced a `SetDefaultNetModeIfBlank` function to set the
default network-mode on Linux. Windows did not have a default network,
but did require a separate `ValidateNetMode` implemenation.

The `ContainerConfigWrapper` was expanded to include `NetworkingConfig`
in 2bb3fc1 for API [v1.22], but did
not involve backward-compatiblity / conversion code.

Based on the above, all conversion code present in runconfig is related
to API versions [v1.18] or before. 19a04ef,
and other commits in [moby PR 47155] removed support for API < v1.24, so
this conversion code is no longer needed.

This patch removes the legacy fields from the `ContainerConfigWrapper`,
and removes the corresponding conversion code. The `InnerHostConfig` field
is also renamed, as it is no longer shadowed by the `container.HostConfig`
that was embedded for backward-compatibility.

[v1.18]: https://github.com/moby/moby/blob/837eec064d2d40a4d86acbc6f47fada8263e0d4c/api/common.go#L18
[v1.19]: https://github.com/moby/moby/blob/767df67e3149b83255db0809f6543b449a4f652e/api/common.go#L20
[v1.22]: https://github.com/moby/moby/blob/2bb3fc1bc522059e9be5bd967b6a5c49917f5d0c/api/common.go#L21
[moby PR 47155]: moby#47155
[ContainerHostConfigFromJob]: https://github.com/hqhq/moby/blob/837eec064d2d40a4d86acbc6f47fada8263e0d4c/runconfig/hostconfig.go#L149-L162

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Jun 16, 2024
The runconfig package contained compatibility code to unmarshal API
requests on API < v1.18, and to convert them to current API versions.
These fields were marked as deprecated, but didn't mention relevant API
versions, so some digging was needed to track back history;

API versions before 1.18 accepted top-level `Memory`, `MemorySwap`,
`CpuShares`, and `Cpuset` fields as part of the container create requests.
These fields were not considered "portable", and therefore moved to the
`HostConfig` struct in 837eec0. The
API version at that time was [v1.18]. For backward-compatibility, the
existing top-level fields were kept, and conversion code was added in
[ContainerHostConfigFromJob] to copy their values to `HostConfig` if
present.

A refactor in 767df67 introduced a new
`ContainerConfigWrapper` struct, which embedded the container-config and
a (non-exported) `hostConfigWrapper`. This resulted in an incompatibility
when compiling with gccgo, sn eb97de7
removed the non-exported `hostConfigWrapper`, instead embedding the
`HostConfig` and adding a `CpuSet` field. The API version at that time
was [v1.19].

With the introduction of Windows containers, which did not need conversion
code as it never supported previous API versions, the `ContainerConfigWrapper`
was split to Linux and Windows implementation in f6ed590.
This change introduced a `SetDefaultNetModeIfBlank` function to set the
default network-mode on Linux. Windows did not have a default network,
but did require a separate `ValidateNetMode` implemenation.

The `ContainerConfigWrapper` was expanded to include `NetworkingConfig`
in 2bb3fc1 for API [v1.22], but did
not involve backward-compatiblity / conversion code.

Based on the above, all conversion code present in runconfig is related
to API versions [v1.18] or before. 19a04ef,
and other commits in [moby PR 47155] removed support for API < v1.24, so
this conversion code is no longer needed.

This patch removes the legacy fields from the `ContainerConfigWrapper`,
and removes the corresponding conversion code. The `InnerHostConfig` field
is also renamed, as it is no longer shadowed by the `container.HostConfig`
that was embedded for backward-compatibility.

[v1.18]: https://github.com/moby/moby/blob/837eec064d2d40a4d86acbc6f47fada8263e0d4c/api/common.go#L18
[v1.19]: https://github.com/moby/moby/blob/767df67e3149b83255db0809f6543b449a4f652e/api/common.go#L20
[v1.22]: https://github.com/moby/moby/blob/2bb3fc1bc522059e9be5bd967b6a5c49917f5d0c/api/common.go#L21
[moby PR 47155]: moby#47155
[ContainerHostConfigFromJob]: https://github.com/hqhq/moby/blob/837eec064d2d40a4d86acbc6f47fada8263e0d4c/runconfig/hostconfig.go#L149-L162

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants