mirror of https://github.com/docker/compose.git
watch: add retry counts to fsync (#2023)
This commit is contained in:
parent
b22dde9f18
commit
ec781687fd
|
@ -643,6 +643,10 @@ func (f *notifyFixture) consumeEventsInBackground(ctx context.Context) chan erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *notifyFixture) fsync() {
|
func (f *notifyFixture) fsync() {
|
||||||
|
f.fsyncWithRetryCount(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *notifyFixture) fsyncWithRetryCount(retryCount int) {
|
||||||
if len(f.paths) == 0 {
|
if len(f.paths) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -650,7 +654,7 @@ func (f *notifyFixture) fsync() {
|
||||||
syncPathBase := fmt.Sprintf("sync-%d.txt", time.Now().UnixNano())
|
syncPathBase := fmt.Sprintf("sync-%d.txt", time.Now().UnixNano())
|
||||||
syncPath := filepath.Join(f.paths[0], syncPathBase)
|
syncPath := filepath.Join(f.paths[0], syncPathBase)
|
||||||
anySyncPath := filepath.Join(f.paths[0], "sync-")
|
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()))
|
f.WriteFile(syncPath, fmt.Sprintf("%s", time.Now()))
|
||||||
|
|
||||||
|
@ -677,7 +681,12 @@ F:
|
||||||
f.events = append(f.events, event)
|
f.events = append(f.events, event)
|
||||||
|
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
|
if retryCount <= 0 {
|
||||||
f.T().Fatalf("fsync: timeout")
|
f.T().Fatalf("fsync: timeout")
|
||||||
|
} else {
|
||||||
|
f.fsyncWithRetryCount(retryCount - 1)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue