Skip to content

Commit 33ea362

Browse files
committed
Don't call tail.Cleanup()
It is only supposed to be called from a process exit handler, and exists as a workaround to a Linux kernel bug that _may_ have existed in some kernels back in early 2014. Calling tail.Cleanup() seems to prevent the process from receiving any further fsnotify notification for the same file again (at least on macOS). Signed-off-by: Jan Dubois <[email protected]>
1 parent 092c99e commit 33ea362

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pkg/hostagent/events/watcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Watch(ctx context.Context, haStdoutPath, haStderrPath string, begin time.Ti
2222
}
2323
defer func() {
2424
_ = haStdoutTail.Stop()
25-
haStdoutTail.Cleanup()
25+
// Do NOT call haStdoutTail.Cleanup(), it prevents the process from ever tailing the file again
2626
}()
2727

2828
haStderrTail, err := tail.TailFile(haStderrPath,
@@ -35,7 +35,7 @@ func Watch(ctx context.Context, haStdoutPath, haStderrPath string, begin time.Ti
3535
}
3636
defer func() {
3737
_ = haStderrTail.Stop()
38-
haStderrTail.Cleanup()
38+
// Do NOT call haStderrTail.Cleanup(), it prevents the process from ever tailing the file again
3939
}()
4040

4141
loop:

pkg/instance/start.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,18 @@ func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) {
115115
}, nil
116116
}
117117

118-
// Start starts the instance.
118+
// Start starts the hostagent in the background, which in turn will start the instance.
119+
// Start will listen to hostagent events and log them to STDOUT until either the instance
120+
// is running, or has failed to start.
121+
//
122+
// The `limactl` argument allows the caller to specify the full path of the `limactl` executable.
123+
// When called from inside limactl itself it will always be the empty string which uses the name
124+
// of the current executable instead.
125+
//
126+
// The `launchHostAgentForeground` argument makes the hostagent run in the foreground.
127+
// The function will continue to listen and log hostagent events until the instance is
128+
// shut down again.
129+
//
119130
// Start calls Prepare by itself, so you do not need to call Prepare manually before calling Start.
120131
func Start(ctx context.Context, inst *store.Instance, limactl string, launchHostAgentForeground bool) error {
121132
haPIDPath := filepath.Join(inst.Dir, filenames.HostAgentPID)

0 commit comments

Comments
 (0)