Skip to content

ateapi: add atespaced ExternalVolume resource - #3744

Open
hajiler wants to merge 3 commits into
agent-substrate:mainfrom
hajiler:shared-volumes/pr1-external-volume
Open

hajiler wants to merge 3 commits into
agent-substrate:mainfrom
hajiler:shared-volumes/pr1-external-volume

Conversation

@hajiler

@hajiler hajiler commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Part 1 of Shared Volumes #1637 (design: Substrate Shared External Volumes).

Depends on #4021, which frees the ExternalVolumeStatus name. Until it merges, this PR also shows its two commits and hack/verify/proto-breaking.sh fails. Review the last commit.

An ExternalVolume is an atespace-scoped record of a storage volume. For now it is read-only for users, the server will create the record. status.csi is a CSIVolume holding driverName, volumeId and volumeContext, which the node plugin needs to mount the volume.

  • Resource, Postgres tables (000002_external_volumes.sql; external_volumes is ON DELETE RESTRICT to atespaces), store methods and contract tests. external_volume_keys keeps (driver_name, volume_id) unique across atespaces.
  • GetExternalVolume and ListExternalVolumes. There is no Create, Update or Delete RPC.
  • OpenFGA external_volume type. Atespace viewers get and list.
  • kubectl ate get external-volume, docs.

Nothing creates an ExternalVolume yet, so the functional tests cover only NOT_FOUND, the empty list, validation and authorization. The store keeps CreateExternalVolume and DeleteExternalVolume for the follow-up that writes records.

CSIVolume carries the same validation tags the fields had before, with +k8s:immutable replaced by +k8s:update=NoModify and NoUnset. validation-gen only generates code for types a request carries, so nothing enforces the tags yet. The two custom checks are kept as ValidateCSIVolumeID and ValidateCSIVolumeContext until a request carries a CSIVolume.

Changed since the earlier review rounds: CreateExternalVolume, DeleteExternalVolume, the global-owner create permission, and kubectl ate {create,delete} external-volume are removed. The fields moved from the top level to status.csi.

Follow-ups:

  1. The server records each volume it provisions for an actor as an ExternalVolume (ateapi: record each actor-provisioned volume as an ExternalVolume #3746). Validate storage_volume_id path containment when constructing CSI staging directories #2935 (staging path built from the raw volume ID) lands first, since volumeId allows /.
  2. An ImportExternalVolume RPC to register a volume that already exists in the storage system.
  3. Actor references on the record, then sequential and concurrent sharing.

AI use: Claude Code drafted parts of the implementation, the rework to the read-only shape and this description; I reviewed every change.

  • Tests pass: go test -race for cmd/ateapi/... (apivalidation, authz, store on Postgres, controlapi, the functional suite) and cmd/kubectl-ate/...; golangci-lint, gofmt, proto-fmt, boilerplate, codegen. Not run locally: apitool validate, the rest of hack/verify-all.sh. No e2e: nothing creates the resource on a cluster yet.
  • Docs updated

@hajiler hajiler left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Review: Reviewed with a focus on the object shape and how it holds up against the later changes in the series (template reference, actor references on the volume, delete trigger). The handler, store, authz and CLI code follow the Tag precedent closely and read fine.

Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread cmd/ateapi/internal/authz/authorizer.go Resolved
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch 2 times, most recently from c1365a3 to 5d9d73e Compare November 10, 2026 20:37
@hajiler
hajiler marked this pull request as ready for review November 10, 2026 20:41
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread cmd/ateapi/internal/authz/authorizer.go Resolved
Comment thread internal/resources/resourceref.go Resolved
Comment thread cmd/ateapi/internal/authz/authorizer.go Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note on syncing the Shared External Volumes design doc:
This PR is up to date on volume_type, volumes[].external.template (in docs/guides/csi-volumes.md), --volume-context / --preview, and DeleteExternalVolume leaving underlying storage intact, and you noted on ateapi.proto that the ExternalVolumeStatus / storage_volume_id alignment will be handled in the follow-up PR. However, the Shared External Volumes design doc is still outdated on these — could you update the design doc when you get a chance so other docs referencing it stay in sync? Specifically:

  1. volumes[].external nesting (from PR #2653): The design doc (Tab 1 "Changes to ActorTemplate" & Tab 2 CUJs S1, S3, C3, C4) still uses top-level volumes[].externalVolumeTemplate and volumes[].externalVolumeRef instead of volumes[].external.template and volumes[].external.ref (which you flagged on our FusionFS doc).
  2. ExternalVolume fields (from PR #3744): In Tab 1 ("New API Type: ExternalVolume"), update Driver string → volume_type (to match this PR), and add volume_context (map<string, string>).
  3. CLI flags & delete behavior (from PR #3744): Add --volume-context and --preview to the kubectl ate create externalvolume examples, and update Tab 2 S1 (which currently says "the user deletes the ExternalVolume, which deletes the disk", whereas DeleteExternalVolume only removes the Substrate DB record and leaves storage in place).
  4. ExternalVolume.status & ActorStatus volume status (for PR 2): Update the ExternalVolume sketch to nest output-only fields (assigned_actors with ObjectRef actor + string actor_uid, and state) under ExternalVolume.status per API Style Guide §8, note the rename of the existing per-actor ExternalVolumeStatus message (storage_volume_id → volume_id) to avoid colliding with ExternalVolume's status type, and reconcile .status.externalVolumes.volumes[] (Tab 1) vs. .status.actorVolumes[] (Tab 2 S3/D6).

hajiler added a commit to hajiler/substrate that referenced this pull request Nov 11, 2026
Cross-resource references are named after the resource they point to
(docs/api-style-guide.md 2.3), as agent-substrate#3744 does for its references to the
same resource. Rename ExternalVolumeSource.ref to external_volume before
it is served.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from 5d9d73e to c94af04 Compare November 11, 2026 20:20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for addressing all the review comments.

hajiler added a commit to hajiler/substrate that referenced this pull request Nov 11, 2026
Cross-resource references are named after the resource they point to
(docs/api-style-guide.md 2.3), as agent-substrate#3744 does for its references to the
same resource. Rename ExternalVolumeSource.ref to external_volume before
it is served.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
hajiler added a commit to hajiler/substrate that referenced this pull request Nov 11, 2026
Cross-resource references are named after the resource they point to
(docs/api-style-guide.md 2.3), as agent-substrate#3744 does for its references to the
same resource. Rename ExternalVolumeSource.ref to external_volume before
it is served.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread cmd/ateapi/internal/authz/model.fga Resolved
Comment thread cmd/ateapi/internal/authz/model.fga Resolved
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from c94af04 to 731ccef Compare November 12, 2026 20:12
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from 731ccef to 9b016b2 Compare November 17, 2026 18:02
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from 9b016b2 to 2b2c893 Compare November 18, 2026 22:48
hajiler added a commit to hajiler/substrate that referenced this pull request Nov 18, 2026
Cross-resource references are named after the resource they point to
(docs/api-style-guide.md 2.3), as agent-substrate#3744 does for its references to the
same resource. Rename ExternalVolumeSource.ref to external_volume before
it is served.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@hajiler hajiler left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jetski Review: Adversarial review focused on API style, validation, and naming/proto evolution.

Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread cmd/ateapi/internal/store/store.go Resolved
Comment thread cmd/ateapi/internal/authz/model.fga Resolved
Comment thread docs/guides/csi-volumes.md Resolved

@hajiler hajiler left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was produced by an AI agent (Jetski) run by the PR author.

Adversarial pass over the store, migration, authz wiring, handlers and CLI at c0a3d7b, skipping everything already raised in the earlier threads. I found no correctness or security bug. Create writes the record and its external_volume_keys row in one transaction. All four RPCs have defaultRPCPermissions entries. Get and Delete check the external_volume object and an all-atespaces List needs a global viewer. The migration only adds tables. go build, go test -race ./cmd/ateapi/... (including the Postgres-backed suites), apitool validate, proto-breaking, codegen, gofmt, go-modules and licenses all pass. Rebase onto #4021: the only non-generated mention of the old actor-side name is the comment above ValidateCustom_ExternalVolume_VolumeId (ExternalVolumeStatus.storage_volume_id, apivalidation/external_volume.go:50). It is left over from the earlier self-contained thread. After #4021 it names a message that no longer exists, and later the wrong one. The rebase also has to drop #4021's two buf.yaml ignore_only entries. There is no status field yet to type ExternalVolumeStatus. Commit message, outside the diff: "its Postgres table" should be "tables" (external_volumes and external_volume_keys). The paragraph that starts "This adds ..." lists the diff, which AGENTS.md asks not to restate. The global (driver_name, volume_id) uniqueness, the one rule beyond CRUD, is not mentioned.

Comment thread cmd/ateapi/internal/authz/registry.go Resolved
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch 3 times, most recently from c2f3b0d to ebf8afd Compare December 1, 2026 20:55
@hajiler hajiler changed the title ateapi: add the ExternalVolume resource ateapi: add the read-only ExternalVolume resource Dec 1, 2026
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from ebf8afd to 93b9945 Compare December 1, 2026 23:38
@hajiler hajiler changed the title ateapi: add the read-only ExternalVolume resource ateapi: add atespaced ExternalVolume resource Dec 1, 2026
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
Comment thread docs/reference/kubectl-ate.md Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
@msau42 Michelle Au (msau42) added area/api User-facing API changes kind/feature An enhancement / feature request or implementation area/storage labels Dec 2, 2026
ActorStatus.external_volumes is typed ExternalVolumes, with one
ExternalVolumeStatus per mounted volume. Shared volumes add an
atespace-scoped ExternalVolume resource, and the API style guide requires
its status field to be typed ExternalVolumeStatus. Both messages are
still behind the ExternalVolumes preview gate, so rename them now to
ActorExternalVolumes and ActorExternalVolumeStatus. Field names, numbers
and validation tags are unchanged.

ate-api-server stores actors as binary protobuf keyed by field number,
and protojson writes field names, so stored data and JSON output are
unaffected. What changes is the Go type names in the public
api/ateapi/v1 package and the proto full names.

buf breaking reports the rename as a deleted message and a retyped
field. Add a temporary ignore_only entry in buf.yaml for
PACKAGE_MESSAGE_NO_DELETE and FIELD_SAME_TYPE on ateapi.proto. The entry
disables both rules for every message in the file, so remove it when the
ExternalVolume API lands.

Signed-off-by: Elijah Rodriguez <elijahrb@google.com>
ignore_only keys on the file path, so the two entries disable
PACKAGE_MESSAGE_NO_DELETE and FIELD_SAME_TYPE for every message in
ateapi.proto. Say so in the comment and in the preview-gates doc, and
mark the entries with a TODO to remove them when the ExternalVolume API
lands.

Signed-off-by: Elijah Rodriguez <elijahrb@google.com>
An ExternalVolume is an atespace-scoped record of a storage volume. The
server writes it: status.csi holds the CSI driver name, the volume ID and
the volume context the node plugin needs to mount the volume. An atespace
cannot be deleted while it holds one.

This adds the resource, its Postgres tables and store methods, the OpenFGA
type, the Get and List RPCs, and kubectl ate get external-volume. Both RPCs
require the ExternalVolumes preview gate. external_volume_keys keeps
(driver_name, volume_id) unique across atespaces.

Nothing creates an ExternalVolume yet. Actor templates still provision a
volume per actor from external.template. The server-side creation and an
import RPC come in later changes.

Signed-off-by: Elijah Rodriguez-Beltran <elijahrb@google.com>
@hajiler
hajiler force-pushed the shared-volumes/pr1-external-volume branch from 93b9945 to 17c3a48 Compare December 2, 2026 04:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api User-facing API changes area/storage kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants