mirror of https://github.com/docker/compose.git
ignore error parsing container number label, just warn
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
ea32fc99e1
commit
19d6ca9c5d
|
@ -226,10 +226,7 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
|
||||||
updated[i] = container
|
updated[i] = container
|
||||||
}
|
}
|
||||||
|
|
||||||
next, err := nextContainerNumber(containers)
|
next := nextContainerNumber(containers)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for i := 0; i < expected-actual; i++ {
|
for i := 0; i < expected-actual; i++ {
|
||||||
// Scale UP
|
// Scale UP
|
||||||
number := next + i
|
number := next + i
|
||||||
|
@ -370,18 +367,23 @@ func shouldWaitForDependency(serviceName string, dependencyConfig types.ServiceD
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func nextContainerNumber(containers []moby.Container) (int, error) {
|
func nextContainerNumber(containers []moby.Container) int {
|
||||||
max := 0
|
max := 0
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
n, err := strconv.Atoi(c.Labels[api.ContainerNumberLabel])
|
s, ok := c.Labels[api.ContainerNumberLabel]
|
||||||
|
if !ok {
|
||||||
|
logrus.Warnf("container %s is missing %s label", c.ID, api.ContainerNumberLabel)
|
||||||
|
}
|
||||||
|
n, err := strconv.Atoi(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
logrus.Warnf("container %s has invalid %s label: %s", c.ID, api.ContainerNumberLabel, s)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if n > max {
|
if n > max {
|
||||||
max = n
|
max = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return max + 1, nil
|
return max + 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue