From a8819763b4370325efc9d221c45423399cb0f303 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Fri, 16 Apr 2021 08:56:16 +0200 Subject: [PATCH] scale must ignore oneoff containers Signed-off-by: Nicolas De Loof --- local/compose/containers.go | 5 +++++ local/compose/convergence.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/local/compose/containers.go b/local/compose/containers.go index 4b57ad7d4..588b3ce1f 100644 --- a/local/compose/containers.go +++ b/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 diff --git a/local/compose/convergence.go b/local/compose/convergence.go index 559919603..4a19c15a5 100644 --- a/local/compose/convergence.go +++ b/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