Skip to content

api/types/container: remove support for config mac address#51152

Closed
austinvazquez wants to merge 1 commit intomoby:masterfrom
austinvazquez:remove-support-for-container-config-mac-address
Closed

api/types/container: remove support for config mac address#51152
austinvazquez wants to merge 1 commit intomoby:masterfrom
austinvazquez:remove-support-for-container-config-mac-address

Conversation

@austinvazquez
Copy link
Contributor

@austinvazquez austinvazquez commented Oct 9, 2025

- What I did
Dropped support for the container wide MacAddress in container configuration.

Deprecated in API v1.44; the MacAddress field is no longer supported starting with API v1.52. Newer clients will no longer be able to send the field even when specifying the lower API versions. The daemon will continue to migrate the field when using API v1.44 - v1.51. Specifying the field will now result in an error for v1.52 and onwards.

- How I did it
🧹 ... 🗑️

- How to verify it

- Human readable description for the release notes

api/types/container: removed support for container wide MAC address. Use endpoint settings when connecting a container to a network for MAC address assignments.

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

@austinvazquez austinvazquez added this to the 29.0.0 milestone Oct 9, 2025
@austinvazquez austinvazquez self-assigned this Oct 9, 2025
@austinvazquez austinvazquez added release-blocker PRs we want to block a release on impact/api impact/changelog kind/refactor PR's that refactor, or clean-up code labels Oct 9, 2025
@austinvazquez austinvazquez force-pushed the remove-support-for-container-config-mac-address branch from 3e2a370 to 857f9b9 Compare October 13, 2025 13:41
@austinvazquez austinvazquez force-pushed the remove-support-for-container-config-mac-address branch from 857f9b9 to 010dc7c Compare October 13, 2025 14:24
@austinvazquez austinvazquez marked this pull request as ready for review October 13, 2025 14:35
@austinvazquez
Copy link
Contributor Author

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestAPIErrorJSON (0.01s)
docker_api_test.go:46: assertion failed: error is not nil: Post "http://%2Frun%2Fdocker%2Ftmp.TkszL2DnWV%2Fdocker.sock/containers/create": EOF
--- FAIL: TestDockerAPISuite/TestAPIErrorJSON (0.01s)

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the remove-support-for-container-config-mac-address branch from 010dc7c to c020b45 Compare October 13, 2025 15:15
@austinvazquez
Copy link
Contributor Author

=== FAIL: amd64.integration-cli TestDockerAPISuite/TestAPIErrorJSON (0.01s)
docker_api_test.go:46: assertion failed: error is not nil: Post "http://%2Frun%2Fdocker%2Ftmp.TkszL2DnWV%2Fdocker.sock/containers/create": EOF
--- FAIL: TestDockerAPISuite/TestAPIErrorJSON (0.01s)

Root caused this test failure to be from embedding the backend.ContainerConfig type within the backend.CreateContainerRequest type using the pointer notation. This resulted in effectively having double pointer embedding.

Comment on lines -235 to -239
// Regression test for https://github.com/moby/moby/issues/47441
// Migration of a container-wide MAC address to the new per-endpoint setting,
// where NetworkMode uses network id, and the key in endpoint settings is the
// network name.
func TestWatchtowerCreate(t *testing.T) {
Copy link
Contributor Author

@austinvazquez austinvazquez Oct 13, 2025

Choose a reason for hiding this comment

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

Client would no longer support sending MacAddress field even when pinned to an older API version. cc: @robmry WDYT, should this test be made to use the API endpoint instead?

Copy link
Contributor

@robmry robmry Oct 13, 2025

Choose a reason for hiding this comment

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

As it's still in the API, it should be tested - but it looks like I added unit test TestHandleMACAddressBC as part of the fix that added this integration test. It tests handleMACAddressBC, and the fix was all in there. So that's probably good enough.

But the test above (TestInspectCfgdMAC) is no longer testing what it says, and that one's not really unit testable...

// Regression test for https://github.com/moby/moby/issues/47228 - check that a
// generated MAC address is not included in the Config section of 'inspect'
// output, but a configured address is.

TestMacAddressIsAppliedToMainNetworkWithShortID is also there to regression test an issue related to the container-wide MAC address not being mapped to the right network. Changing its API request to use the per-network MAC address means it's not doing anything very useful.

So, yes - if there is a way to test against the API, that'd be good ... are you thinking of just sending a blob of JSON from the test?

(This may be heresy - but alternatively we could just stick with the deprecated field in the API? We can still return an error if it's used in API 1.52 - and if we drop support for old versions of the API at some point, we can delete these tests and all the messy compatibility code at the same time. Until then, if we have to maintain this stuff, not having the field in the API makes things a bit more tricky?)

} else if ep.MacAddress != deprecatedMacAddress {
return "", errdefs.InvalidParameter(errors.New("the container-wide MAC address must match the endpoint-specific MAC address for the main network, or be left empty"))

// API v1.44 to v1.51: the container-wide MacAddress field is deprecated but still supported for backward-compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

Did we actually support though? Because at least the client removed the field on API v1.44 and up, and I think the daemon also ignored it, so other than the swagger mentioning the field (which it shouldn't have) the field effectively was already removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted some offline. Between 1.44 and 1.52 the daemon would migrate the mac address to the endpoint for requests coming in with the field set and warn users to use the endpoint settings instead.

Reference:

ep.MacAddress = deprecatedMacAddress

@austinvazquez
Copy link
Contributor Author

Superseded by #51194

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.

3 participants