diff --git a/pkg/compose/start.go b/pkg/compose/start.go index 971c7a02c..7caeb3057 100644 --- a/pkg/compose/start.go +++ b/pkg/compose/start.go @@ -257,6 +257,11 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo service := container.Labels[api.ServiceLabel] switch event.Status { case "stop": + if inspected.State.Running { + // on sync+restart action the container stops -> dies -> start -> restart + // we do not want to stop the current container, we want to restart it + return nil + } if _, ok := watched[container.ID]; ok { eType := api.ContainerEventStopped if utils.Contains(replaced, container.ID) { @@ -279,6 +284,11 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo watched[container.ID] = restarted + 1 // Container terminated. willRestart := inspected.State.Restarting + if inspected.State.Running { + // on sync+restart action inspected.State.Restarting is false, + // however the container is already running before it restarts + willRestart = true + } eType := api.ContainerEventExit if utils.Contains(replaced, container.ID) { diff --git a/pkg/e2e/watch_test.go b/pkg/e2e/watch_test.go index 677b080a0..1f7106bb8 100644 --- a/pkg/e2e/watch_test.go +++ b/pkg/e2e/watch_test.go @@ -34,7 +34,6 @@ import ( ) func TestWatch(t *testing.T) { - t.Skip("Skipping watch tests until we can figure out why they are flaky/failing") services := []string{"alpine", "busybox", "debian"} for _, svcName := range services {