Skip to content

Commit ea4ccf6

Browse files
jhrotkoglours
authored andcommitted
Fix stop on file chane for sync-restart action
Signed-off-by: Joana Hrotko <[email protected]>
1 parent b1850ea commit ea4ccf6

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/compose/start.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
257257
service := container.Labels[api.ServiceLabel]
258258
switch event.Status {
259259
case "stop":
260+
if inspected.State.Running {
261+
// on sync+restart action the container stops -> dies -> start -> restart
262+
// we do not want to stop the current container, we want to restart it
263+
return nil
264+
}
260265
if _, ok := watched[container.ID]; ok {
261266
eType := api.ContainerEventStopped
262267
if utils.Contains(replaced, container.ID) {
@@ -279,6 +284,11 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
279284
watched[container.ID] = restarted + 1
280285
// Container terminated.
281286
willRestart := inspected.State.Restarting
287+
if inspected.State.Running {
288+
// on sync+restart action inspected.State.Restarting is false,
289+
// however the container is already running before it restarts
290+
willRestart = true
291+
}
282292

283293
eType := api.ContainerEventExit
284294
if utils.Contains(replaced, container.ID) {

pkg/e2e/watch_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
)
3535

3636
func TestWatch(t *testing.T) {
37-
t.Skip("Skipping watch tests until we can figure out why they are flaky/failing")
3837

3938
services := []string{"alpine", "busybox", "debian"}
4039
for _, svcName := range services {

0 commit comments

Comments
 (0)