diff --git a/cluster/swarm/cluster.go b/cluster/swarm/cluster.go index 99f2d0fae7..c29dcf7f99 100644 --- a/cluster/swarm/cluster.go +++ b/cluster/swarm/cluster.go @@ -118,13 +118,13 @@ func (c *Cluster) generateUniqueID() string { func (c *Cluster) CreateContainer(config *cluster.ContainerConfig, name string, authConfig *dockerclient.AuthConfig) (*cluster.Container, error) { container, err := c.createContainer(config, name, false, authConfig) - // fails with image not found, then try to reschedule with soft-image-affinity + // fails with image not found, then try to reschedule with image-affinity if err != nil { bImageNotFoundError, _ := regexp.MatchString(`image \S* not found`, err.Error()) if bImageNotFoundError && !config.HaveNodeConstraint() { // Check if the image exists in the cluster - // If exists, retry with a soft-image-affinity - if image := c.Image(config.Image); image != nil { + // If exists, retry with a image-affinity + if c.Image(config.Image) != nil { container, err = c.createContainer(config, name, true, authConfig) } } @@ -132,7 +132,7 @@ func (c *Cluster) CreateContainer(config *cluster.ContainerConfig, name string, return container, err } -func (c *Cluster) createContainer(config *cluster.ContainerConfig, name string, withSoftImageAffinity bool, authConfig *dockerclient.AuthConfig) (*cluster.Container, error) { +func (c *Cluster) createContainer(config *cluster.ContainerConfig, name string, withImageAffinity bool, authConfig *dockerclient.AuthConfig) (*cluster.Container, error) { c.scheduler.Lock() // Ensure the name is available @@ -146,8 +146,8 @@ func (c *Cluster) createContainer(config *cluster.ContainerConfig, name string, config.SetSwarmID(swarmID) configTemp := config - if withSoftImageAffinity { - configTemp.AddAffinity("image==~" + config.Image) + if withImageAffinity { + configTemp.AddAffinity("image==" + config.Image) } nodes, err := c.scheduler.SelectNodesForContainer(c.listNodes(), configTemp)