From ec781687fdc3cb9014524ae88f26a0bf7d8ef4a7 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Thu, 8 Aug 2019 19:28:47 -0400 Subject: [PATCH] watch: add retry counts to fsync (#2023) --- pkg/watch/notify_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index a3a2bcc7..34215aaf 100644 --- a/pkg/watch/notify_test.go +++ b/pkg/watch/notify_test.go @@ -643,6 +643,10 @@ func (f *notifyFixture) consumeEventsInBackground(ctx context.Context) chan erro } func (f *notifyFixture) fsync() { + f.fsyncWithRetryCount(3) +} + +func (f *notifyFixture) fsyncWithRetryCount(retryCount int) { if len(f.paths) == 0 { return } @@ -650,7 +654,7 @@ func (f *notifyFixture) fsync() { syncPathBase := fmt.Sprintf("sync-%d.txt", time.Now().UnixNano()) syncPath := filepath.Join(f.paths[0], syncPathBase) anySyncPath := filepath.Join(f.paths[0], "sync-") - timeout := time.After(time.Second) + timeout := time.After(250 * time.Millisecond) f.WriteFile(syncPath, fmt.Sprintf("%s", time.Now())) @@ -677,7 +681,12 @@ F: f.events = append(f.events, event) case <-timeout: - f.T().Fatalf("fsync: timeout") + if retryCount <= 0 { + f.T().Fatalf("fsync: timeout") + } else { + f.fsyncWithRetryCount(retryCount - 1) + } + return } } }