Browse code

daemon: fix build after revendoring api module

Complete the removal of the deprecated network structs by dropping the
remaining references in daemon code.

Signed-off-by: Cory Snider <csnider@mirantis.com>

Cory Snider authored on 2025/09/12 06:06:30
Showing 6 changed files
... ...
@@ -215,10 +215,6 @@ func (daemon *Daemon) updateEndpointNetworkSettings(cfg *config.Config, ctr *con
215 215
 		return err
216 216
 	}
217 217
 
218
-	if ctr.HostConfig.NetworkMode == network.DefaultNetwork {
219
-		ctr.NetworkSettings.Bridge = cfg.BridgeConfig.Iface
220
-	}
221
-
222 218
 	return nil
223 219
 }
224 220
 
... ...
@@ -12,7 +12,6 @@ import (
12 12
 	"github.com/moby/moby/api/types/storage"
13 13
 	"github.com/moby/moby/v2/daemon/config"
14 14
 	"github.com/moby/moby/v2/daemon/container"
15
-	"github.com/moby/moby/v2/daemon/network"
16 15
 	"github.com/moby/moby/v2/daemon/server/backend"
17 16
 	"github.com/moby/moby/v2/errdefs"
18 17
 )
... ...
@@ -49,19 +48,10 @@ func (daemon *Daemon) ContainerInspect(ctx context.Context, name string, options
49 49
 	}
50 50
 
51 51
 	networkSettings := &containertypes.NetworkSettings{
52
-		NetworkSettingsBase: containertypes.NetworkSettingsBase{ //nolint:staticcheck // ignore SA1019: NetworkSettingsBase is deprecated in v28.4.
53
-			Bridge:                 ctr.NetworkSettings.Bridge,
54
-			SandboxID:              ctr.NetworkSettings.SandboxID,
55
-			SandboxKey:             ctr.NetworkSettings.SandboxKey,
56
-			Ports:                  ports,
57
-			HairpinMode:            ctr.NetworkSettings.HairpinMode,
58
-			LinkLocalIPv6Address:   ctr.NetworkSettings.LinkLocalIPv6Address,
59
-			LinkLocalIPv6PrefixLen: ctr.NetworkSettings.LinkLocalIPv6PrefixLen,
60
-			SecondaryIPAddresses:   ctr.NetworkSettings.SecondaryIPAddresses,
61
-			SecondaryIPv6Addresses: ctr.NetworkSettings.SecondaryIPv6Addresses,
62
-		},
63
-		DefaultNetworkSettings: getDefaultNetworkSettings(ctr.NetworkSettings.Networks),
64
-		Networks:               apiNetworks,
52
+		SandboxID:  ctr.NetworkSettings.SandboxID,
53
+		SandboxKey: ctr.NetworkSettings.SandboxKey,
54
+		Ports:      ports,
55
+		Networks:   apiNetworks,
65 56
 	}
66 57
 
67 58
 	mountPoints := ctr.GetMountPoints()
... ...
@@ -239,23 +229,3 @@ func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, err
239 239
 		Pid:         pid,
240 240
 	}, nil
241 241
 }
242
-
243
-// getDefaultNetworkSettings creates the deprecated structure that holds the information
244
-// about the bridge network for a container.
245
-func getDefaultNetworkSettings(networks map[string]*network.EndpointSettings) containertypes.DefaultNetworkSettings { //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
246
-	nw, ok := networks[networktypes.NetworkBridge]
247
-	if !ok || nw.EndpointSettings == nil {
248
-		return containertypes.DefaultNetworkSettings{} //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
249
-	}
250
-
251
-	return containertypes.DefaultNetworkSettings{ //nolint:staticcheck // ignore SA1019: DefaultNetworkSettings is deprecated in v28.4.
252
-		EndpointID:          nw.EndpointSettings.EndpointID,
253
-		Gateway:             nw.EndpointSettings.Gateway,
254
-		GlobalIPv6Address:   nw.EndpointSettings.GlobalIPv6Address,
255
-		GlobalIPv6PrefixLen: nw.EndpointSettings.GlobalIPv6PrefixLen,
256
-		IPAddress:           nw.EndpointSettings.IPAddress,
257
-		IPPrefixLen:         nw.EndpointSettings.IPPrefixLen,
258
-		IPv6Gateway:         nw.EndpointSettings.IPv6Gateway,
259
-		MacAddress:          nw.EndpointSettings.MacAddress,
260
-	}
261
-}
... ...
@@ -13,18 +13,12 @@ import (
13 13
 // Settings stores configuration details about the daemon network config
14 14
 // TODO Windows. Many of these fields can be factored out.,
15 15
 type Settings struct {
16
-	Bridge                 string
17
-	SandboxID              string
18
-	SandboxKey             string
19
-	HairpinMode            bool
20
-	LinkLocalIPv6Address   string
21
-	LinkLocalIPv6PrefixLen int
22
-	Networks               map[string]*EndpointSettings
23
-	Service                *clustertypes.ServiceConfig
24
-	Ports                  container.PortMap
25
-	SecondaryIPAddresses   []networktypes.Address
26
-	SecondaryIPv6Addresses []networktypes.Address
27
-	HasSwarmEndpoint       bool
16
+	SandboxID        string
17
+	SandboxKey       string
18
+	Networks         map[string]*EndpointSettings
19
+	Service          *clustertypes.ServiceConfig
20
+	Ports            container.PortMap
21
+	HasSwarmEndpoint bool
28 22
 }
29 23
 
30 24
 // EndpointSettings is a package local wrapper for
... ...
@@ -42,6 +42,11 @@ PY_TEST_OPTIONS="$PY_TEST_OPTIONS --deselect=tests/integration/models_containers
42 42
 # automatically in linking containers. Thus, this test is expected to fail — skip it. See https://github.com/moby/moby/pull/50719
43 43
 PY_TEST_OPTIONS="${PY_TEST_OPTIONS} --deselect=tests/integration/api_container_test.py::CreateContainerTest::test_create_with_links"
44 44
 
45
+# The NetworkSettings.MacAddress field has been deprecated since Docker 1.9, and starting with v29.0, the Engine won't
46
+# include it in API respoonses. Thus, this test is expected to fail — skip it.
47
+# See https://github.com/moby/moby/pull/50846 and https://github.com/moby/moby/pull/50957
48
+PY_TEST_OPTIONS="${PY_TEST_OPTIONS} --deselect=tests/integration/api_container_test.py::CreateContainerTest::test_create_with_mac_address"
49
+
45 50
 (
46 51
 	bundle .integration-daemon-start
47 52
 
... ...
@@ -6,75 +6,10 @@ import (
6 6
 
7 7
 // NetworkSettings exposes the network settings in the api
8 8
 type NetworkSettings struct {
9
-	NetworkSettingsBase
10
-	DefaultNetworkSettings
11
-	Networks map[string]*network.EndpointSettings
12
-}
13
-
14
-// NetworkSettingsBase holds networking state for a container when inspecting it.
15
-//
16
-// Deprecated: Most fields in NetworkSettingsBase are deprecated. Fields which aren't deprecated will move to
17
-// NetworkSettings in v29.0, and this struct will be removed.
18
-type NetworkSettingsBase struct {
19
-	Bridge     string  // Deprecated: This field is only set when the daemon is started with the --bridge flag specified.
20 9
 	SandboxID  string  // SandboxID uniquely represents a container's network stack
21 10
 	SandboxKey string  // SandboxKey identifies the sandbox
22 11
 	Ports      PortMap // Ports is a collection of PortBinding indexed by Port
23
-
24
-	// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
25
-	//
26
-	// Deprecated: This field is never set and will be removed in a future release.
27
-	HairpinMode bool
28
-	// LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix
29
-	//
30
-	// Deprecated: This field is never set and will be removed in a future release.
31
-	LinkLocalIPv6Address string
32
-	// LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address
33
-	//
34
-	// Deprecated: This field is never set and will be removed in a future release.
35
-	LinkLocalIPv6PrefixLen int
36
-	SecondaryIPAddresses   []network.Address // Deprecated: This field is never set and will be removed in a future release.
37
-	SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
38
-}
39
-
40
-// DefaultNetworkSettings holds the networking state for the default bridge, if the container is connected to that
41
-// network.
42
-//
43
-// Deprecated: this struct is deprecated since Docker v1.11 and will be removed in v29. You should look for the default
44
-// network in NetworkSettings.Networks instead.
45
-type DefaultNetworkSettings struct {
46
-	// EndpointID uniquely represents a service endpoint in a Sandbox
47
-	//
48
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
49
-	EndpointID string
50
-	// Gateway holds the gateway address for the network
51
-	//
52
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
53
-	Gateway string
54
-	// GlobalIPv6Address holds network's global IPv6 address
55
-	//
56
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
57
-	GlobalIPv6Address string
58
-	// GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
59
-	//
60
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
61
-	GlobalIPv6PrefixLen int
62
-	// IPAddress holds the IPv4 address for the network
63
-	//
64
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
65
-	IPAddress string
66
-	// IPPrefixLen represents mask length of network's IPv4 address
67
-	//
68
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
69
-	IPPrefixLen int
70
-	// IPv6Gateway holds gateway address specific for IPv6
71
-	//
72
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
73
-	IPv6Gateway string
74
-	// MacAddress holds the MAC address for the network
75
-	//
76
-	// Deprecated: This field will be removed in v29. You should look for the default network in NetworkSettings.Networks instead.
77
-	MacAddress string
12
+	Networks   map[string]*network.EndpointSettings
78 13
 }
79 14
 
80 15
 // NetworkSettingsSummary provides a summary of container's networks
... ...
@@ -34,12 +34,6 @@ type CreateRequest struct {
34 34
 	CheckDuplicate *bool `json:",omitempty"`
35 35
 }
36 36
 
37
-// Address represents an IP address
38
-type Address struct {
39
-	Addr      string
40
-	PrefixLen int
41
-}
42
-
43 37
 // ServiceInfo represents service parameters with the list of service's tasks
44 38
 type ServiceInfo struct {
45 39
 	VIP          string