execute: transparent per-session mount recovery on stale FUSE

This commit is contained in:
Levi Neely 2026-05-21 08:49:36 +02:00
parent d00a15093d
commit 4188d5946b
2 changed files with 26 additions and 0 deletions

View File

@ -107,6 +107,7 @@ var languagePatterns = map[string][]*regexp.Regexp{
// Dispatch routes a named execute tool call. // Dispatch routes a named execute tool call.
func (e *Server) Dispatch(ctx context.Context, name string, args json.RawMessage) (string, error) { func (e *Server) Dispatch(ctx context.Context, name string, args json.RawMessage) (string, error) {
e.remountIfStale()
if len(e.allowExecutors) > 0 && !e.allowExecutors[name] { if len(e.allowExecutors) > 0 && !e.allowExecutors[name] {
return "", fmt.Errorf("executor %q not permitted in this agent context", name) return "", fmt.Errorf("executor %q not permitted in this agent context", name)
} }

View File

@ -403,6 +403,31 @@ func (e *Server) startMount(sessionID string) {
e.envExtra["OLLIE"] = mnt e.envExtra["OLLIE"] = mnt
} }
// remountIfStale checks the per-session FUSE mount health and re-establishes it if broken.
// Must be called without envMu held.
func (e *Server) remountIfStale() {
e.envMu.RLock()
mnt := e.mountPath
proc := e.mountProc
e.envMu.RUnlock()
if mnt == "" || proc == nil {
return
}
if _, err := os.Stat(filepath.Join(mnt, "s")); err == nil {
return
}
// Mount is stale — tear down and restart.
e.envMu.Lock()
defer e.envMu.Unlock()
exec.Command("fusermount", "-u", e.mountPath).Run() //nolint:errcheck
syscall.Kill(e.mountProc.Pid, syscall.SIGKILL) //nolint:errcheck
e.mountProc = nil
e.mountPath = ""
if uname := e.envExtra["OLLIE_UNAME"]; uname != "" {
e.startMount(uname)
}
}
// Close tears down the per-session FUSE mount. // Close tears down the per-session FUSE mount.
func (e *Server) Close() { func (e *Server) Close() {
e.envMu.Lock() e.envMu.Lock()