浏览代码

Merge pull request #1562 from docker/atoi

scale must ignore oneoff containers
Nicolas De loof 4 年之前
父节点
当前提交
9f23d9e992
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 5 0
      local/compose/containers.go
  2. 1 1
      local/compose/convergence.go

+ 5 - 0
local/compose/containers.go

@@ -83,6 +83,11 @@ func isNotService(services ...string) containerPredicate {
 	}
 }
 
+func isNotOneOff(c moby.Container) bool {
+	v, ok := c.Labels[oneoffLabel]
+	return !ok || v == "False"
+}
+
 // filter return Containers with elements to match predicate
 func (containers Containers) filter(predicate containerPredicate) Containers {
 	var filtered Containers

+ 1 - 1
local/compose/convergence.go

@@ -52,7 +52,7 @@ func (s *composeService) ensureScale(ctx context.Context, project *types.Project
 		return nil, nil, err
 	}
 	observedState := cState.GetContainers()
-	actual := observedState.filter(isService(service.Name))
+	actual := observedState.filter(isService(service.Name)).filter(isNotOneOff)
 	scale, err := getScale(service)
 	if err != nil {
 		return nil, nil, err