Update executor changes from swarmkit
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
ee030251f2
commit
96a27cf093
3 changed files with 9 additions and 11 deletions
|
@ -144,13 +144,13 @@ func (c *containerAdapter) removeNetworks(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *containerAdapter) create(ctx context.Context, backend executorpkg.Backend) error {
|
||||
func (c *containerAdapter) create(ctx context.Context) error {
|
||||
var cr types.ContainerCreateResponse
|
||||
var err error
|
||||
version := httputils.VersionFromContext(ctx)
|
||||
validateHostname := versions.GreaterThanOrEqualTo(version, "1.24")
|
||||
|
||||
if cr, err = backend.CreateManagedContainer(types.ContainerCreateConfig{
|
||||
if cr, err = c.backend.CreateManagedContainer(types.ContainerCreateConfig{
|
||||
Name: c.container.name(),
|
||||
Config: c.container.config(),
|
||||
HostConfig: c.container.hostConfig(),
|
||||
|
@ -166,13 +166,13 @@ func (c *containerAdapter) create(ctx context.Context, backend executorpkg.Backe
|
|||
|
||||
if nc != nil {
|
||||
for n, ep := range nc.EndpointsConfig {
|
||||
if err := backend.ConnectContainerToNetwork(cr.ID, n, ep); err != nil {
|
||||
if err := c.backend.ConnectContainerToNetwork(cr.ID, n, ep); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
|
||||
if err := c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ func (c *containerAdapter) remove(ctx context.Context) error {
|
|||
})
|
||||
}
|
||||
|
||||
func (c *containerAdapter) createVolumes(ctx context.Context, backend executorpkg.Backend) error {
|
||||
func (c *containerAdapter) createVolumes(ctx context.Context) error {
|
||||
// Create plugin volumes that are embedded inside a Mount
|
||||
for _, mount := range c.container.task.Spec.GetContainer().Mounts {
|
||||
if mount.Type != api.MountTypeVolume {
|
||||
|
@ -275,7 +275,7 @@ func (c *containerAdapter) createVolumes(ctx context.Context, backend executorpk
|
|||
req := c.container.volumeCreateRequest(&mount)
|
||||
|
||||
// Check if this volume exists on the engine
|
||||
if _, err := backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
|
||||
if _, err := c.backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
|
||||
// TODO(amitshukla): Today, volume create through the engine api does not return an error
|
||||
// when the named volume with the same parameters already exists.
|
||||
// It returns an error if the driver name is different - that is a valid error
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
// Most operations against docker's API are done through the container name,
|
||||
// which is unique to the task.
|
||||
type controller struct {
|
||||
backend executorpkg.Backend
|
||||
task *api.Task
|
||||
adapter *containerAdapter
|
||||
closed chan struct{}
|
||||
|
@ -41,7 +40,6 @@ func newController(b executorpkg.Backend, task *api.Task) (*controller, error) {
|
|||
}
|
||||
|
||||
return &controller{
|
||||
backend: b,
|
||||
task: task,
|
||||
adapter: adapter,
|
||||
closed: make(chan struct{}),
|
||||
|
@ -86,7 +84,7 @@ func (r *controller) Prepare(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// Make sure all the volumes that the task needs are created.
|
||||
if err := r.adapter.createVolumes(ctx, r.backend); err != nil {
|
||||
if err := r.adapter.createVolumes(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -128,7 +126,7 @@ func (r *controller) Prepare(ctx context.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := r.adapter.create(ctx, r.backend); err != nil {
|
||||
if err := r.adapter.create(ctx); err != nil {
|
||||
if isContainerCreateNameConflict(err) {
|
||||
if _, err := r.adapter.inspect(ctx); err != nil {
|
||||
return err
|
||||
|
|
|
@ -51,7 +51,7 @@ func (s *DockerSwarmSuite) TestSwarmInit(c *check.C) {
|
|||
c.Assert(spec.Dispatcher.HeartbeatPeriod, checker.Equals, uint64(11*time.Second))
|
||||
|
||||
c.Assert(d.Leave(true), checker.IsNil)
|
||||
|
||||
time.Sleep(500 * time.Millisecond) // https://github.com/docker/swarmkit/issues/1421
|
||||
out, err = d.Cmd("swarm", "init")
|
||||
c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
||||
|
||||
|
|
Loading…
Reference in a new issue