Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon: raise default minimum API version to v1.24 #46887

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Dec 4, 2023

daemon: raise default minimum API version to v1.24

The daemon currently provides support for API versions all the way back to v1.12, which is the version of the API that shipped with docker 1.0. On Windows, the minimum supported version is v1.24.

Such old versions of the client are rare, and supporting older API versions has accumulated significant amounts of code to remain backward-compatible (which is largely untested, and a "best-effort" at most).

This patch updates the minimum API version to v1.24, which is the fallback API version used when API-version negotiation fails. The intent is to start deprecating older API versions, but no code is removed yet as part of this patch, and a DOCKER_MIN_API_VERSION environment variable is added, which allows overriding the minimum version (to allow restoring the behavior from before this patch).

docker version
Client:
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:50:49 2023
 OS/Arch:           linux/arm64
 Context:           default

Server:
 Engine:
  Version:          dev
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.3
  Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
  Built:            Mon Dec  4 15:22:17 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v1.7.9
  GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Trying to use an older version of the API produces an error:

DOCKER_API_VERSION=1.23 docker version
Client:
 Version:           24.0.2
 API version:       1.23 (downgraded from 1.43)
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:50:49 2023
 OS/Arch:           linux/arm64
 Context:           default
Error response from daemon: client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

To restore the previous minimum, users can start the daemon with the DOCKER_MIN_API_VERSION environment variable set:

DOCKER_MIN_API_VERSION=1.12 dockerd

API 1.12 is the oldest supported API version on Linux;

docker version
Client:
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:50:49 2023
 OS/Arch:           linux/arm64
 Context:           default

Server:
 Engine:
  Version:          dev
  API version:      1.44 (minimum version 1.12)
  Go version:       go1.21.3
  Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
  Built:            Mon Dec  4 15:22:17 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v1.7.9
  GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
 runc:
  Version:          1.1.10
  GitCommit:        v1.1.10-0-g18a0cb0
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

When using the DOCKER_MIN_API_VERSION with a version of the API that is not supported, an error is produced when starting the daemon;

DOCKER_MIN_API_VERSION=1.11 dockerd --validate
invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: 1.11

DOCKER_MIN_API_VERSION=1.45 dockerd --validate
invalid DOCKER_MIN_API_VERSION: maximum supported API version is 1.44: 1.45

Specifying a malformed API version also produces the same error;

DOCKER_MIN_API_VERSION=hello dockerd --validate
invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: hello

- What I did

- How I did it

- How to verify it

- Description for the changelog

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

@rumpl
Copy link
Member

rumpl commented Dec 4, 2023

Version 1.24 of the API came out in 2017, do we want to move to some more recent version?

@thaJeztah
Copy link
Member Author

Version 1.24 of the API came out in 2017, do we want to move to some more recent version?

We probably need more updates for that, because 1.24 is the fallback version used if API-version negotiation fails.

@thaJeztah
Copy link
Member Author

Looks like a bunch of tests are failing that are related to testing old API versions, so some more changes are needed.

cmd/dockerd/daemon.go Outdated Show resolved Hide resolved
api/common.go Outdated
// included in the API response), we assume the API server uses the most
// recent version before negotiation was introduced.
FallbackVersion = "1.24"

// DefaultVersion of Current REST API
DefaultVersion = "1.44"
Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps change to Version (if we remove "unversioned === default === current" version

Copy link
Member Author

Choose a reason for hiding this comment

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

^^ didn't change this one yet, but can do so in a follow-up.

api/common.go Outdated Show resolved Hide resolved
daemon/config/config.go Outdated Show resolved Hide resolved
@thaJeztah
Copy link
Member Author

Moved the test changes to #46891

daemon/config/config.go Outdated Show resolved Hide resolved
The daemon currently provides support for API versions all the way back
to v1.12, which is the version of the API that shipped with docker 1.0. On
Windows, the minimum supported version is v1.24.

Such old versions of the client are rare, and supporting older API versions
has accumulated significant amounts of code to remain backward-compatible
(which is largely untested, and a "best-effort" at most).

This patch updates the minimum API version to v1.24, which is the fallback
API version used when API-version negotiation fails. The intent is to start
deprecating older API versions, but no code is removed yet as part of this
patch, and a DOCKER_MIN_API_VERSION environment variable is added, which
allows overriding the minimum version (to allow restoring the behavior from
before this patch).

With this patch the daemon defaults to API v1.24 as minimum:

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.24)
      Go version:       go1.21.3
      Git commit:       0322a29
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

Trying to use an older version of the API produces an error:

    DOCKER_API_VERSION=1.23 docker version
    Client:
     Version:           24.0.2
     API version:       1.23 (downgraded from 1.43)
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default
    Error response from daemon: client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

To restore the previous minimum, users can start the daemon with the
DOCKER_MIN_API_VERSION environment variable set:

    DOCKER_MIN_API_VERSION=1.12 dockerd

API 1.12 is the oldest supported API version on Linux;

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.12)
      Go version:       go1.21.3
      Git commit:       0322a29
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

When using the `DOCKER_MIN_API_VERSION` with a version of the API that
is not supported, an error is produced when starting the daemon;

    DOCKER_MIN_API_VERSION=1.11 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: 1.11

    DOCKER_MIN_API_VERSION=1.45 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: maximum supported API version is 1.44: 1.45

Specifying a malformed API version also produces the same error;

    DOCKER_MIN_API_VERSION=hello dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: hello

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the 25.0.0 milestone Dec 5, 2023
@thaJeztah
Copy link
Member Author

Version 1.24 of the API came out in 2017, do we want to move to some more recent version?

Noticed I didn't answer this question; version 1.24 is currently the "fallback" version for clients when attempting API-version negotiation; if negotiation fails, they fall back to API 1.24.

We discussed this in the maintainers call;

  • We'll use this PR to start deprecation of older API versions
  • Also consider completing the deprecation of "unversioned" API endpoints (with the exception of the /_ping endpoint); currently "unversioned" is equivalent to "latest", and instead we'll freeze the version; see Deprecate unversioned Engine API usage #46889
  • We'll start incrementing the "fallback version" in clients; this means we can start phasing out older API versions once older clients become obsolete (In the "happy path" they would still be able to connect to their default API version, but won't fallback to a still supported API version)

@thaJeztah thaJeztah merged commit 6af9204 into moby:master Dec 5, 2023
105 checks passed
@thaJeztah thaJeztah deleted the minimum_api_version branch December 5, 2023 23:15
@thaJeztah thaJeztah self-assigned this Dec 6, 2023
vvoland added a commit to vvoland/docker-py that referenced this pull request Mar 7, 2024
25.0 raised the minimum supported API verison: moby/moby#46887

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
vvoland added a commit to vvoland/docker-py that referenced this pull request Mar 7, 2024
25.0 raised the minimum supported API verison: moby/moby#46887

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
vvoland added a commit to vvoland/docker-py that referenced this pull request Mar 14, 2024
25.0 raised the minimum supported API verison: moby/moby#46887

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
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