Skip to content

Commit ec78168

Browse files
nicksndeloof
authored andcommitted
watch: add retry counts to fsync (docker#2023)
1 parent b22dde9 commit ec78168

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/watch/notify_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,14 +643,18 @@ func (f *notifyFixture) consumeEventsInBackground(ctx context.Context) chan erro
643643
}
644644

645645
func (f *notifyFixture) fsync() {
646+
f.fsyncWithRetryCount(3)
647+
}
648+
649+
func (f *notifyFixture) fsyncWithRetryCount(retryCount int) {
646650
if len(f.paths) == 0 {
647651
return
648652
}
649653

650654
syncPathBase := fmt.Sprintf("sync-%d.txt", time.Now().UnixNano())
651655
syncPath := filepath.Join(f.paths[0], syncPathBase)
652656
anySyncPath := filepath.Join(f.paths[0], "sync-")
653-
timeout := time.After(time.Second)
657+
timeout := time.After(250 * time.Millisecond)
654658

655659
f.WriteFile(syncPath, fmt.Sprintf("%s", time.Now()))
656660

@@ -677,7 +681,12 @@ F:
677681
f.events = append(f.events, event)
678682

679683
case <-timeout:
680-
f.T().Fatalf("fsync: timeout")
684+
if retryCount <= 0 {
685+
f.T().Fatalf("fsync: timeout")
686+
} else {
687+
f.fsyncWithRetryCount(retryCount - 1)
688+
}
689+
return
681690
}
682691
}
683692
}

0 commit comments

Comments
 (0)