Skip to content

Commit a40f835

Browse files
Only look at the base path in readiness check (#200)
This is to ensure the readiness check for service containers, which depends on a file notification, works on Windows. We were comparing the event name with the path, but this path wasn't localized, so the match would fail on Windows. Instead, we can just look at the base of the path since we only set up the watcher on the containing directory.
1 parent 8dc4c27 commit a40f835

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

task/orchestrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (o *Orchestrator) waitForReadiness(ctx context.Context) (err error) {
144144
for {
145145
select {
146146
case event, ok := <-watcher.Events:
147-
if ok && event.Has(fsnotify.Create) && event.Name == readinessFilePath {
147+
if ok && event.Has(fsnotify.Create) && filepath.Base(event.Name) == filepath.Base(readinessFilePath) {
148148
return nil
149149
}
150150
case err, ok := <-watcher.Errors:

task/orchestrator_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ func TestOrchestrator_waitForReadiness(t *testing.T) {
319319
defer cancel()
320320

321321
o := Orchestrator{}
322-
o.config.ReadinessFilePath = filepath.Join(t.TempDir(), "ready")
322+
// Test a slash-separated path to ensure the readiness check handles it across different platforms
323+
o.config.ReadinessFilePath = filepath.ToSlash(filepath.Join(t.TempDir(), "ready"))
323324

324325
go func() {
325326
time.Sleep(250 * time.Millisecond)

0 commit comments

Comments
 (0)