Add transparent ReadWriteMany (RWX) volume support via NFS#194
Draft
sjmiller609 wants to merge 2 commits intomainfrom
Draft
Add transparent ReadWriteMany (RWX) volume support via NFS#194sjmiller609 wants to merge 2 commits intomainfrom
sjmiller609 wants to merge 2 commits intomainfrom
Conversation
Volumes can now be attached read-write to multiple instances simultaneously. When a second rw attachment is requested, the volume is automatically loop-mounted on the host and exported via NFS. Subsequent instances mount the volume over NFS instead of as a block device, enabling shared read-write access without filesystem corruption. Key changes: - New nfsManager handles loop mount, /etc/exports, and exportfs lifecycle - AttachVolume transparently upgrades to NFS on concurrent rw attachments - DetachVolume tears down NFS when the last NFS consumer detaches - Guest init gains an "nfs" mount mode (NFSv4, hard mount) - Config disk skips device slot allocation for NFS-served volumes - Instance creation excludes NFS volumes from the hypervisor disk list - NFS host IP derived from network bridge gateway at startup NFS is purely an internal implementation detail — no public API changes. The access mode is determined per-attachment by the existing readonly field, not by a per-volume property. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add an explicit AccessMode enum (ReadWriteOnce, ReadOnlyMany, ReadWriteMany) to the attach volume request. This replaces the implicit rw+rw=NFS behavior with an explicit opt-in model: - ReadWriteOnce: exclusive rw via block device (default, no change) - ReadOnlyMany: read-only, multiple instances (maps from readonly=true) - ReadWriteMany: shared rw via NFS (only mode that triggers NFS) The existing readonly field is deprecated but still works with identical semantics. Neither legacy path triggers NFS. When both fields are set, access_mode takes precedence. Validation rules enforce that different access modes cannot be mixed on the same volume (e.g., RWO + RWX = conflict). Changes: OpenAPI spec (AccessMode enum, deprecated readonly), regenerated oapi.go, domain types, volume manager attach logic, storage persistence, and 9 new tests (36 total pass). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✱ Stainless preview buildsThis PR will update the Edit this comment to update it. It will appear in the SDK's changelogs. ✅ hypeman-typescript studio · code · diff
✅ hypeman-openapi studio · code · diff
✅ hypeman-go studio · code · diff
This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push. |
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.
Summary
Adds support for attaching volumes read-write to multiple instances simultaneously (ReadWriteMany / RWX). When a second rw attachment is requested, the volume is transparently loop-mounted on the host and exported via NFS. New instances mount the volume over the network instead of as a block device, enabling shared read-write access without ext4 corruption.
Design principles:
readonlyfield), not per-volumeKey changes:
lib/volumes/nfs.go— NewnfsManagerhandling loop mount,/etc/exportsmanagement, andexportfslifecyclelib/volumes/manager.go—AttachVolumetransparently upgrades to NFS on concurrent rw attachments;DetachVolumetears down NFS when last NFS consumer detaches; newGetVolumeNFSInfomethodlib/volumes/types.go/storage.go—NFSInfostruct andNFSfield onAttachmentfor persistencelib/system/init/volumes.go— Guest init gains"nfs"mount mode (NFSv4, hard mount with retrans)lib/instances/configdisk.go— NFS-served volumes getmode=nfswith host/export instead of a device path; no device slot consumedlib/instances/create.go— NFS volumes excluded from hypervisor disk listlib/vmconfig/config.go—VolumeMountgainsNFSHostandNFSExportfieldslib/paths/paths.go— NewVolumeNFSMountpath helpercmd/api/main.go— Derives gateway IP from network config and sets NFS host on volume manager at startupKnown limitation: When a volume transitions from block-device to NFS (second rw attach), the first instance continues using its block device. Data written by the first instance won't be visible to NFS consumers until that instance detaches and the block device is released. This is acceptable for the initial implementation — a future enhancement could live-migrate the first attachment to NFS.
Test plan
go test ./lib/volumes/ -v)go vetclean on modified packages