Browse code

Update executor changes from swarmkit

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2016/08/18 14:44:18
Showing 3 changed files
... ...
@@ -144,13 +144,13 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error {
144 144
 	return nil
145 145
 }
146 146
 
147
-func (c *containerAdapter) create(ctx context.Context, backend executorpkg.Backend) error {
147
+func (c *containerAdapter) create(ctx context.Context) error {
148 148
 	var cr types.ContainerCreateResponse
149 149
 	var err error
150 150
 	version := httputils.VersionFromContext(ctx)
151 151
 	validateHostname := versions.GreaterThanOrEqualTo(version, "1.24")
152 152
 
153
-	if cr, err = backend.CreateManagedContainer(types.ContainerCreateConfig{
153
+	if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
154 154
 		Name:       c.container.name(),
155 155
 		Config:     c.container.config(),
156 156
 		HostConfig: c.container.hostConfig(),
... ...
@@ -166,13 +166,13 @@ func (c *containerAdapter) create(ctx context.Context, backend executorpkg.Backe
166 166
 
167 167
 	if nc != nil {
168 168
 		for n, ep := range nc.EndpointsConfig {
169
-			if err := backend.ConnectContainerToNetwork(cr.ID, n, ep); err != nil {
169
+			if err := c.backend.ConnectContainerToNetwork(cr.ID, n, ep); err != nil {
170 170
 				return err
171 171
 			}
172 172
 		}
173 173
 	}
174 174
 
175
-	if err := backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
175
+	if err := c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
176 176
 		return err
177 177
 	}
178 178
 
... ...
@@ -257,7 +257,7 @@ func (c *containerAdapter) remove(ctx context.Context) error {
257 257
 	})
258 258
 }
259 259
 
260
-func (c *containerAdapter) createVolumes(ctx context.Context, backend executorpkg.Backend) error {
260
+func (c *containerAdapter) createVolumes(ctx context.Context) error {
261 261
 	// Create plugin volumes that are embedded inside a Mount
262 262
 	for _, mount := range c.container.task.Spec.GetContainer().Mounts {
263 263
 		if mount.Type != api.MountTypeVolume {
... ...
@@ -275,7 +275,7 @@ func (c *containerAdapter) createVolumes(ctx context.Context, backend executorpk
275 275
 		req := c.container.volumeCreateRequest(&mount)
276 276
 
277 277
 		// Check if this volume exists on the engine
278
-		if _, err := backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
278
+		if _, err := c.backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
279 279
 			// TODO(amitshukla): Today, volume create through the engine api does not return an error
280 280
 			// when the named volume with the same parameters already exists.
281 281
 			// It returns an error if the driver name is different - that is a valid error
... ...
@@ -20,7 +20,6 @@ import (
20 20
 // Most operations against docker's API are done through the container name,
21 21
 // which is unique to the task.
22 22
 type controller struct {
23
-	backend executorpkg.Backend
24 23
 	task    *api.Task
25 24
 	adapter *containerAdapter
26 25
 	closed  chan struct{}
... ...
@@ -41,7 +40,6 @@ func newController(b executorpkg.Backend, task *api.Task) (*controller, error) {
41 41
 	}
42 42
 
43 43
 	return &controller{
44
-		backend: b,
45 44
 		task:    task,
46 45
 		adapter: adapter,
47 46
 		closed:  make(chan struct{}),
... ...
@@ -86,7 +84,7 @@ func (r *controller) Prepare(ctx context.Context) error {
86 86
 	}
87 87
 
88 88
 	// Make sure all the volumes that the task needs are created.
89
-	if err := r.adapter.createVolumes(ctx, r.backend); err != nil {
89
+	if err := r.adapter.createVolumes(ctx); err != nil {
90 90
 		return err
91 91
 	}
92 92
 
... ...
@@ -128,7 +126,7 @@ func (r *controller) Prepare(ctx context.Context) error {
128 128
 		}
129 129
 	}
130 130
 
131
-	if err := r.adapter.create(ctx, r.backend); err != nil {
131
+	if err := r.adapter.create(ctx); err != nil {
132 132
 		if isContainerCreateNameConflict(err) {
133 133
 			if _, err := r.adapter.inspect(ctx); err != nil {
134 134
 				return err
... ...
@@ -51,7 +51,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
51 51
 	c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, uint64(11*time.Second))
52 52
 
53 53
 	c.Assert(d.Leave(true), checker.IsNil)
54
-
54
+	time.Sleep(500 * time.Millisecond) // https://github.com/docker/swarmkit/issues/1421
55 55
 	out, err = d.Cmd("swarm", "init")
56 56
 	c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
57 57