10000 api/types/registry: move `ServiceConfig` legacy field marshaling support into daemon backend by austinvazquez · Pull Request #50826 · moby/moby · GitHub
[go: up one dir, main page]

Skip to content

Conversation

austinvazquez
Copy link
Contributor
@austinvazquez austinvazquez commented Aug 27, 2025

- What I did
Partial of #50740

This change removes the ServiceConfig.MarshalJSON function from and moves the marshaling logic of legacy fields down into the daemon backend.

- How I did it

- How to verify it

- Human readable description for the release notes

api/types/registry: moved `ServiceConfig` legacy field marshaling support into daemon backend

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

@austinvazquez austinvazquez added this to the 29.0.0 milestone Aug 27, 2025
@austinvazquez austinvazquez self-assigned this Aug 27, 2025
@austinvazquez austinvazquez added area/api API impact/api kind/refactor PR's that refactor, or clean-up code release-blocker PRs we want to block a release on labels Aug 27, 2025
@austinvazquez austinvazquez marked this pull request as ready for review August 27, 2025 13:57
@austinvazquez
Copy link
Contributor Author

Placing back in draft. Just realizing from the unit tests MarshalJSON is called indirectly through json.Marshal and therefore will likely not have direct references. Need to verify again if it is used by any of the popular Docker clients.

@austinvazquez austinvazquez marked this pull request as draft August 27, 2025 14:01
Comment on lines -20 to -22
// MarshalJSON implements a custom marshaler to include legacy fields
// in API responses.
func (sc *ServiceConfig) MarshalJSON() ([]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

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

It's used by the daemon to produce API responses for older API versions. If we remove this here, we probably need to create a wrapper struct with marshaling in the daemon API server; see

if versions.LessThan(version, "1.47") {
// Field is omitted in API 1.48 and up, but should still be included
// in older versions, even if no values are set.
info.RegistryConfig.ExtraFields = map[string]any{
"AllowNondistributableArtifactsCIDRs": json.RawMessage(nil),
"AllowNondistributableArtifactsHostnames": json.RawMessage(nil),
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I recall I had a branch somewhere with a more generic package to allow "append old API fields" but not sure if I have preserved it 🙈

@thaJeztah
Copy lin 8000 k
Member

Need to verify again if it is used by any of the popular Docker clients.

It should not be used by clients, only the daemon, but yeah, we need to find a good spot / approach for these. The general attempt here was to allow the daemon to continue serving "legacy" responses (where no sensible content is to be served, other than "the field is there") but being able to remove the fields from the structs before the API is a module (so basically no more opportunities to remove such fields if they're used by the client).

@austinvazquez
Copy link
Contributor Author

Okay that makes more sense. Thanks @thaJeztah. Let me rework this to create a structure down in the daemon and have the legacy fields support there.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the remove-legacy-marshal-json-function branch 2 times, most recently from aaef882 to 27040dd Compare August 27, 2025 16:52
@austinvazquez austinvazquez force-pushed the remove-legacy-marshal-json-function branch from 27040dd to b97382c Compare August 27, 2025 19:49
@austinvazquez austinvazquez changed the title api/types/registry: remove legacy ServiceConfig.MarshalJSON api/types/registry: move ServiceConfig legacy field marshaling support into daemon backend Aug 27, 2025
@austinvazquez austinvazquez marked this pull request as ready for review August 27, 2025 20:13
…atability

This change moves the logic that is used to marshal the legacy extra fields for `registry.ServiceConfig` type to the daemon backend.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the remove-legacy-marshal-json-function branch from b97382c to c9fdad2 Compare August 29, 2025 13:23
@austinvazquez austinvazquez added the area/daemon Core Engine label Aug 29, 2025
@austinvazquez austinvazquez merged commit 229edd0 into moby:master Aug 29, 2025
291 of 296 checks passed
@austinvazquez austinvazquez deleted the remove-legacy-marshal-json-function branch August 29, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api API area/daemon Core Engine impact/api kind/refactor PR's that refactor, or clean-up code release-blocker PRs we want to block a release on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0