Repository navigation
fix(fuse): support fsync on directories - #29
Merged
Merged
Conversation
fsync(2) on a directory returned ENOTSUP: go-fuse answers FSYNCDIR with ENOTSUP unless the node (or directory handle) implements Fsync/Fsyncdir. The OpenHands SDK's atomic_write_text fsyncs the parent directory after the rename and treats any OSError as fatal, so every conversation start on a fusey mount failed with "OSError: [Errno 95] Operation not supported". Implement NodeFsyncer on Node. go-fuse routes both FSYNC (preferred over FileFsyncer) and the FSYNCDIR fallback to it, so the shared sync helper now serves files and directories: flush the active chunk and persist the index, which is also what makes renamed directory entries durable. Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was created by an AI agent (OpenHands) on behalf of the user.
Why
fsync(2)on a directory returnsENOTSUPon a fusey mount. go-fuse answersFSYNCDIRwithENOTSUPunless the node implementsFsync, and fusey only implementedFileHandle.Fsync.This breaks conversation start in OpenHands on fuse-based runtimes. The OpenHands SDK (>= 1.65.0, software-agent-sdk#7081) fsyncs the parent directory at the end of
atomic_write_text, after the rename, and treats anyOSErroras fatal. EveryPOST /api/conversationson theagent-server-fusey:1.65.0-python-fusey0.0.15image returned 500 with:I reproduced this on the beta cluster by running the same syscalls against a live fusey mount in a pod.
fchmod,write,fsync(file)andrenamesucceeded. Onlyfsync(directory)failed withENOTSUP.What changed (
internal/fuse/fs.go):Nodenow implementsfs.NodeFsyncer. go-fuse 2.10.1 prefersNodeFsynceroverFileFsyncerforFSYNC, and falls back to it forFSYNCDIR, so one method serves both files and directories.Fusey.sync: flush the active chunk, then persist the index snapshot. Persisting the index also makes a rename durable, because directory entries live in the index.FileHandle.Fsyncand itsFileFsyncerassertion are removed. go-fuse would never call it now thatNode.Fsynctakes precedence.Directory fsync on a read-only (as-of) mount behaves the same as file fsync does today.
Validation
go build ./...,go vet ./internal/fuse/andgo test ./...pass.internal/fuse/fs_test.go:TestFsyncDirectory: directory fsync succeeds, and the entry is in the persisted index.TestAtomicWriteSequence: replays the SDK's temp file,fchmod,fsync, rename, parent-directoryfsyncsequence.TestNodeFsyncWithoutMount: callsNode.Fsyncdirectly with no mount./dev/fuse, soTestFsyncDirectoryandTestAtomicWriteSequenceskipped there, and onlyTestNodeFsyncWithoutMountran. I also did not run the new tests against the old code to show them failing. Please confirm that CI (if it has FUSE) or a local run executes the two mounted tests:go test ./internal/fuse/ -run 'Fsync|AtomicWrite' -v.v1_fuseimage tag in OpenHands, and retry a conversation start on beta.@tofarr can click here to continue refining the PR