Skip to content

Add ExternalVolumeClass resource, CLI, and volume provisioning - #3751

Open
Vu Le (lekhoavu2909) wants to merge 5 commits into
agent-substrate:mainfrom
lekhoavu2909:evc-pr3-handlers
Open

Vu Le (lekhoavu2909) wants to merge 5 commits into
agent-substrate:mainfrom
lekhoavu2909:evc-pr3-handlers

Conversation

@lekhoavu2909

@lekhoavu2909 Vu Le (lekhoavu2909) commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the ExternalVolumeClass API resource, PostgreSQL storage, request validation, OpenFGA authorization, Control service RPC handlers, kubectl ate CLI commands (get, create -f, and delete), and actor volume provisioning from ExternalVolumeClass (including forwarding mount_options to CSI VolumeCapability.Mount.MountFlags).

An ExternalVolumeClass is a global-scoped, immutable resource whose csi field names the CSI driver (csi.driver_name), driver-specific CreateVolume parameters (csi.parameters), and mount options (csi.mount_options) used to provision and mount external volumes, replacing the Kubernetes StorageClass reference on ActorTemplate. ExternalVolumeTemplate.storage_class_name remains supported alongside external_volume_class until callers switch over in #3806 and StorageClass support is removed in #3816. Consolidates #3742, #3743, #3751, #3752, #3774, and #3776 into one PR with incremental commits for review.

  • ExternalVolumeClass proto message (with nested csi backend), validation, and apitool registration
  • PostgreSQL 000002_external_volume_classes.sql migration, store.Interface, atepg CRUD, defaults, and contract tests
  • OpenFGA model, contextual tuple, and authz helpers
  • Create/Get/List/DeleteExternalVolumeClass RPCs, request validation, permission registry, and apitool example
  • Resource model and authorization docs
  • RPCService and ServiceImpl Control handlers and functional tests
  • ExternalVolumeTemplate.external_volume_class field, union validation, and validation tests
  • Volume resolver, provisioning wiring, CSI MountFlags forwarding, and unit and functional tests
  • ExternalVolumeClass printer, kubectl ate get/create/delete commands, unit tests, and CLI reference docs

Part of #3754

AI use: AI-assisted, I reviewed and tested it.

Breaking change: no. Adds the external_volume_classes table via migration and keeps ExternalVolumeTemplate.storage_class_name working alongside external_volume_class. CreateExternalVolumeClass requires the ExternalVolumes preview gate, while Get, List, and Delete remain available when the gate is off. StorageClass mountOptions are now forwarded to CSI MountFlags where they were previously ignored.

  • Tests pass
  • Docs updated

@lekhoavu2909
Vu Le (lekhoavu2909) marked this pull request as ready for review November 10, 2026 22:49
@lekhoavu2909
Vu Le (lekhoavu2909) marked this pull request as draft November 10, 2026 22:50
@lekhoavu2909
Vu Le (lekhoavu2909) marked this pull request as ready for review November 11, 2026 00:15
@lekhoavu2909 Vu Le (lekhoavu2909) changed the title ateapi: control handlers for ExternalVolumeClass CRUD ateapi: add the ExternalVolumeClass resource Nov 11, 2026
@lekhoavu2909 Vu Le (lekhoavu2909) changed the title ateapi: add the ExternalVolumeClass resource Add ExternalVolumeClass API, CLI, and volume provisioning Nov 17, 2026
@lekhoavu2909 Vu Le (lekhoavu2909) changed the title Add ExternalVolumeClass API, CLI, and volume provisioning Add ExternalVolumeClass resource, CLI, and volume provisioning Nov 17, 2026
Comment thread api/ateapi/v1/ateapi.proto Resolved
@hajiler

hajiler commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

/lgtm

@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the evc-pr3-handlers branch 2 times, most recently from 0ff37fe to 58c7650 Compare November 24, 2026 19:03
@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the evc-pr3-handlers branch 3 times, most recently from 48afc09 to 414722a Compare November 25, 2026 19:09
Comment thread api/ateapi/v1/ateapi.proto Resolved
@Sneha-at

Copy link
Copy Markdown
Collaborator

🤖 Suggest aligning the length validation on ExternalVolumeClass with how #3744 validates ExternalVolume, and with what was asked on #3822.

On #3822, review asked for byte-based limits because hand-written len(x) > N checks count bytes while +k8s:maxLength counts characters (validate.MaxLength uses utf8.RuneCountInString): #3822 (comment). Review there also asked for driver names to be capped at the CSI 63-character limit: #3822 (comment). #3744 follows this: volume_id is maxBytes=256 with a custom check that rejects control characters and surrounding whitespace, and volume_context uses eachKey minLength=1, eachKey/eachVal maxBytes, and a custom total-size check that rejects NUL bytes. Each field's doc comment also states its limits with units.

  1. parameters: maxLength counts characters, there is no total bound, and empty keys are allowed. The worst case is 32 × (128 + 256) = 12,288 characters, which is above the 4 KiB CSI limit for map fields. StorageClass rejects empty keys. Suggest:
    // `parameters` are passed unchanged to the driver's CSI CreateVolume call.
    // Keys and values are the driver's own, so the map is only bounded: at most
    // 32 entries, keys of 1 to 128 bytes, values of at most 256 bytes, 4 KiB in
    // total, and no NUL bytes.
    //
    // +k8s:optional
    // +k8s:maxProperties=32
    // +k8s:eachKey=+k8s:minLength=1
    // +k8s:eachKey=+k8s:maxBytes=128
    // +k8s:eachVal=+k8s:maxBytes=256
    // +k8s:customValidation # at most 4 KiB in total, the CSI limit for map fields; no NUL bytes
  2. mount_options: same issue. 32 × 256 = 8,192 characters is above the 4 KiB CSI limit for mount_flags. Suggest:
    // `mount_options` are passed to the CSI driver as
    // `VolumeCapability.Mount.MountFlags` at mount time: at most 32 options of
    // 1 to 256 bytes each, 4 KiB in total, with no control characters or
    // surrounding whitespace.
    //
    // +k8s:optional
    // +k8s:maxItems=32
    // +k8s:listType=atomic
    // +k8s:eachVal=+k8s:minLength=1
    // +k8s:eachVal=+k8s:maxBytes=256
    // +k8s:customValidation # at most 4 KiB in total, the CSI limit for mount_flags; no control characters or surrounding whitespace
    The character rule matches ateapi: add atespaced ExternalVolume resource #3744's volume_id.
  3. ExternalVolumeStatus.mount_options (field 6) and ateletpb.ExternalVolumeSource.mount_options (field 5): these copies also use maxLength=256. Give them the same tags and wording, and have all three call one shared ValidateCustom helper so the limits can't drift.
  4. driver_name: state the limit and its source in the doc comment, as ateapi: add atespaced ExternalVolume resource #3744 does: "a DNS-1123 subdomain of at most 63 characters, as the CSI spec requires". Move the substrate.io/ prefix into an internal (-- Internal volume plugins carry a substrate.io/ prefix. --) note. maxLength=63 is right here because it is a name.
  5. One validator for driver names: this PR uses +k8s:format=ate-volume-type-name (as ExternalVolumeStatus.volume_type does on main), while ateapi: add atespaced ExternalVolume resource #3744 uses +k8s:customValidation # CSI driver name syntax for the same rule. Can the two PRs agree on one?
  6. Code spans: per docs/api-style-guide.md section 13.2, the new comments should put driver_name, parameters, mount_options, external_volume_class, storage_class_name, metadata.atespace and VolumeCapability.Mount.MountFlags in code spans, as ateapi: add atespaced ExternalVolume resource #3744 does.

Why the totals here are 4 KiB and not #3744's 40 KiB: volume_context is filled in by the driver, so #3744 accepts 10× the CSI limit. Class parameters and mount_options are written by users and sent to the driver, so they should stay within the CSI limit itself. It is easy to loosen later and a breaking change to tighten.

Tests: a key of 65 × é (65 characters, 130 bytes) should fail, and rows at the 128/129-byte, 256/257-byte, 4096/4097-byte totals and 32/33-item bounds, plus empty-key and NUL/control-character rows, for the class and both copies.

@Sneha-at

Copy link
Copy Markdown
Collaborator

/lgtm

@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the evc-pr3-handlers branch 3 times, most recently from 6b6a5ce to 54c6a4b Compare November 30, 2026 23:42
Comment thread internal/volume/csi/plugin.go Resolved
Comment thread api/ateapi/v1/ateapi.proto Resolved
@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the evc-pr3-handlers branch 2 times, most recently from ab08eb7 to 6b3ca59 Compare December 1, 2026 20:29
@lekhoavu2909 Vu Le (lekhoavu2909) changed the title Add ExternalVolumeClass resource, CLI, and volume provisioning Add ExternalVolumeClass resource, CLI, and volume provisioning Dec 1, 2026
… by ObjectRef), ExternalVolumeTemplate.external_volume_class, CRUD/List RPCs, and apitool examples/tests.

Signed-off-by: Vu Le <vulk@google.com>
…ver_configs), store.Interface methods, atepg CRUD, and contract/Postgres tests.

Signed-off-by: Vu Le <vulk@google.com>
…ries, RPCService/ServiceImpl handlers, and functional tests.

Signed-off-by: Vu Le <vulk@google.com>
…gh ateletpb/atelet, and volume lifecycle tests.

Signed-off-by: Vu Le <vulk@google.com>

// storage_class_name names the cluster-scoped Kubernetes StorageClass to
// create the volume from. Required.
// `storage_class_name` names the cluster-scoped Kubernetes StorageClass to

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

add a todo for replacing this with external_volume_class.

// +k8s:required
// +k8s:maxLength=63
// +k8s:format=k8s-long-name
string driver_name = 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be an objectref to CSIDriverConfig

…horization/resource-model docs.

Signed-off-by: Vu Le <vulk@google.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants