Browse code

Windows OCI: Remove endpoint list

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/09/18 10:17:51
Showing 6 changed files
... ...
@@ -69,34 +69,6 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
69 69
 	s.Root.Path = c.BaseFS
70 70
 	s.Root.Readonly = c.HostConfig.ReadonlyRootfs
71 71
 
72
-	// In s.Windows.Networking
73
-	// Connect all the libnetwork allocated networks to the container
74
-	var epList []string
75
-	if c.NetworkSettings != nil {
76
-		for n := range c.NetworkSettings.Networks {
77
-			sn, err := daemon.FindNetwork(n)
78
-			if err != nil {
79
-				continue
80
-			}
81
-
82
-			ep, err := c.GetEndpointInNetwork(sn)
83
-			if err != nil {
84
-				continue
85
-			}
86
-
87
-			data, err := ep.DriverInfo()
88
-			if err != nil {
89
-				continue
90
-			}
91
-			if data["hnsid"] != nil {
92
-				epList = append(epList, data["hnsid"].(string))
93
-			}
94
-		}
95
-	}
96
-	s.Windows.Networking = &windowsoci.WindowsNetworking{
97
-		EndpointList: epList,
98
-	}
99
-
100 72
 	// In s.Windows.Resources
101 73
 	// @darrenstahlmsft implement these resources
102 74
 	cpuShares := uint64(c.HostConfig.CPUShares)
... ...
@@ -51,10 +51,37 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain
51 51
 		layerOpts.LayerPaths = append([]string{layerPath}, layerOpts.LayerPaths...)
52 52
 	}
53 53
 
54
+	// Get endpoints for the libnetwork allocated networks to the container
55
+	var epList []string
56
+	if container.NetworkSettings != nil {
57
+		for n := range container.NetworkSettings.Networks {
58
+			sn, err := daemon.FindNetwork(n)
59
+			if err != nil {
60
+				continue
61
+			}
62
+
63
+			ep, err := container.GetEndpointInNetwork(sn)
64
+			if err != nil {
65
+				continue
66
+			}
67
+
68
+			data, err := ep.DriverInfo()
69
+			if err != nil {
70
+				continue
71
+			}
72
+			if data["hnsid"] != nil {
73
+				epList = append(epList, data["hnsid"].(string))
74
+			}
75
+		}
76
+	}
77
+
54 78
 	// Now build the full set of options
55 79
 	createOptions = append(createOptions, &libcontainerd.FlushOption{IgnoreFlushesDuringBoot: !container.HasBeenStartedBefore})
56 80
 	createOptions = append(createOptions, hvOpts)
57 81
 	createOptions = append(createOptions, layerOpts)
82
+	if epList != nil {
83
+		createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{Endpoints: epList})
84
+	}
58 85
 
59 86
 	return &createOptions, nil
60 87
 }
... ...
@@ -106,10 +106,6 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
106 106
 		HvPartition:             false,
107 107
 	}
108 108
 
109
-	if spec.Windows.Networking != nil {
110
-		configuration.EndpointList = spec.Windows.Networking.EndpointList
111
-	}
112
-
113 109
 	if spec.Windows.Resources != nil {
114 110
 		if spec.Windows.Resources.CPU != nil {
115 111
 			if spec.Windows.Resources.CPU.Shares != nil {
... ...
@@ -151,6 +147,9 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
151 151
 		}
152 152
 		if l, ok := option.(*LayerOption); ok {
153 153
 			layerOpt = l
154
+		}
155
+		if n, ok := option.(*NetworkEndpointsOption); ok {
156
+			configuration.EndpointList = n.Endpoints
154 157
 			continue
155 158
 		}
156 159
 	}
... ...
@@ -32,13 +32,13 @@ type Stats hcsshim.Statistics
32 32
 // Resources defines updatable container resource values.
33 33
 type Resources struct{}
34 34
 
35
-// ServicingOption is an empty CreateOption with a no-op application that signifies
35
+// ServicingOption is a CreateOption with a no-op application that signifies
36 36
 // the container needs to be used for a Windows servicing operation.
37 37
 type ServicingOption struct {
38 38
 	IsServicing bool
39 39
 }
40 40
 
41
-// FlushOption is an empty CreateOption that signifies if the container should be
41
+// FlushOption is a CreateOption that signifies if the container should be
42 42
 // started with flushes ignored until boot has completed. This is an optimisation
43 43
 // for first boot of a container.
44 44
 type FlushOption struct {
... ...
@@ -61,6 +61,12 @@ type LayerOption struct {
61 61
 	LayerPaths []string
62 62
 }
63 63
 
64
+// NetworkEndpointsOption is a CreateOption that provides the runtime list
65
+// of network endpoints to which a container should be attached during its creation.
66
+type NetworkEndpointsOption struct {
67
+	Endpoints []string
68
+}
69
+
64 70
 // Checkpoint holds the details of a checkpoint (not supported in windows)
65 71
 type Checkpoint struct {
66 72
 	Name string
... ...
@@ -34,3 +34,8 @@ func (h *HyperVIsolationOption) Apply(interface{}) error {
34 34
 func (h *LayerOption) Apply(interface{}) error {
35 35
 	return nil
36 36
 }
37
+
38
+// Apply for the network endpoints option is a no-op.
39
+func (s *NetworkEndpointsOption) Apply(interface{}) error {
40
+	return nil
41
+}
... ...
@@ -37,8 +37,6 @@ type Spec struct {
37 37
 type Windows struct {
38 38
 	// Resources contains information for handling resource constraints for the container
39 39
 	Resources *WindowsResources `json:"resources,omitempty"`
40
-	// Networking contains the platform specific network settings for the container.
41
-	Networking *WindowsNetworking `json:"networking,omitempty"`
42 40
 }
43 41
 
44 42
 // Process contains information to start a specific application inside the container.
... ...
@@ -116,12 +114,6 @@ type Mount struct {
116 116
 	Options []string `json:"options,omitempty"`
117 117
 }
118 118
 
119
-// WindowsNetworking contains the platform specific network settings for the container
120
-type WindowsNetworking struct {
121
-	// List of endpoints to be attached to the container
122
-	EndpointList []string `json:"endpoints,omitempty"`
123
-}
124
-
125 119
 // WindowsStorage contains storage resource management settings
126 120
 type WindowsStorage struct {
127 121
 	// Specifies maximum Iops for the system drive