Browse Source

Fix stop on file chane for sync-restart action

Signed-off-by: Joana Hrotko <[email protected]>
Joana Hrotko 1 year ago
parent
commit
ea4ccf639d
2 changed files with 10 additions and 1 deletions
  1. 10 0
      pkg/compose/start.go
  2. 0 1
      pkg/e2e/watch_test.go

+ 10 - 0
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) {

+ 0 - 1
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 {