Skip to content

Commit

Permalink
Fix stop on file chane for sync-restart action
Browse files Browse the repository at this point in the history
Signed-off-by: Joana Hrotko <[email protected]>
  • Loading branch information
jhrotko authored and glours committed Jul 25, 2024
1 parent b1850ea commit ea4ccf6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/compose/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/e2e/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ea4ccf6

Please sign in to comment.