Skip to content

cli/command/system/runInfo: set client API defaults, and negotiated API version when available - #4507

Open
thaJeztah wants to merge 2 commits into
docker:masterfrom
thaJeztah:lazy_info
Open

cli/command/system/runInfo: set client API defaults, and negotiated API version when available#4507
thaJeztah wants to merge 2 commits into
docker:masterfrom
thaJeztah:lazy_info

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

cli/command/system/runInfo: set negotiated API version when available

The current logic was ignoring (e.g.) --format=json formats, and was
only setting the negotiated API version if no format was specified.

While we do want to avoid calling the API if possible, we do already
check if the given template requires a server connection, so let's
move updating the API version to that block.

cli/command/system/newClientVersion: initialize with default API version

Set the APIVersion and DefaultAPIVersion fields to the default version,
as that's the version the client assumes without making a API connection
to do version negotiation.

⚠️ One change worth mentioning is that this means that the API version will
differ, depending on the format:

If no server information is fetched:

docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
"1.44"

If server information is fetched:

docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
"1.43"

An alternative could be to leave the ApiVersion field empty if no
negotiation took place.

- Description for the changelog

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

@codecov-commenter

codecov-commenter commented Nov 23, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 59.05%. Comparing base (fc99fe2) to head (c0482fd).

Additional details and impacted files
@@ Coverage Diff @@## master #4507 +/- ##
==========================================
- Coverage 59.05% 59.05% -0.01% 
==========================================
Files 357 357 Lines 29843 29846 +3 ==========================================
+ Hits 17624 17625 +1 - Misses 11241 11243 +2 
Partials 978 978 
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

vvoland
vvoland previously approved these changes Nov 24, 2023
Arch: arch(),
Context: contextName,
Version: version.Version,
APIVersion: api.DefaultVersion,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If no server information is fetched:

docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
"1.44"

If server information is fetched:

docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
"1.43"

An alternative could be to leave the ApiVersion field empty if no negotiation took place.

Hmm not sure about this one.

On one side it's weird for the version to be different depending on the format, on the other side side being empty is also not great.

I think leaving it empty if no negotiation took place would be slightly more useful:

  • It's already that way so there's no existing expectation that it's always non-empty
  • Empty value is better than misleading value as it's easier to notice
  • The CLI APIVersion that's not impacted by the server negotiation is already there in DefaultAPIVersion and docker version --format='{{ json .Client }}' | jq .ApiVersion

@thaJeztahthaJeztah modified the milestones: 25.0.0, 26.0.0Jan 19, 2024
@vvolandvvoland modified the milestones: 26.0.0, 27.0.0Mar 14, 2024
@vvolandvvoland modified the milestones: 27.0.0, 28.0.0Jun 20, 2024
@thaJeztahthaJeztah modified the milestones: 28.0.0, 28.0.5Mar 31, 2025
The current logic was ignoring (e.g.) `--format=json` formats, and was
only setting the negotiated API version if no format was specified.
While we do want to avoid calling the API if possible, we do already
check if the given template requires a server connection, so let's
move updating the API version to that block.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Set the APIVersion and DefaultAPIVersion fields to the default version,
as that's the version the client assumes without making a API connection
to do version negotiation.
One change worth mentioning is that this means that the API version will
differ, depending on the format:
If no server information is fetched:
docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
"1.44"
If server information is fetched:
docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
"1.43"
An alternative could be to leave the ApiVersion field empty if no
negotiation took place.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztahthaJeztah modified the milestones: 28.1.1, 28.1.2Apr 23, 2025
@thaJeztahthaJeztah modified the milestones: 28.1.2, 28.2.0, 29.0.0May 15, 2025
@thaJeztahthaJeztah removed this from the 29.0.0 milestone Jan 13, 2026
@thaJeztahthaJeztah added this to the 29.2.0 milestone Jan 13, 2026
@thaJeztahthaJeztah modified the milestones: 29.2.0, 29.2.1, 29.3.0Jan 26, 2026
@thaJeztahthaJeztah modified the milestones: 29.3.0, 29.3.1Mar 4, 2026
@thaJeztahthaJeztah modified the milestones: 29.4.0, 29.4.1Apr 3, 2026
@thaJeztahthaJeztah modified the milestones: 29.4.1, 29.5.0Apr 20, 2026
@thaJeztahthaJeztah modified the milestones: 29.5.0, 29.6.0May 7, 2026
@thaJeztahthaJeztah modified the milestones: 29.6.0, 29.7.0Jun 12, 2026
@vvolandvvoland modified the milestones: 29.7.0, 29.8.0Jul 30, 2026
Sign up for freeto 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.

3 participants

@thaJeztah@codecov-commenter@vvoland