Repository navigation
feat(server): reject resource names that are not RFC 1123 labels - #406
Merged
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
cursor Bot
pushed a commit
to mvanhorn/ax
that referenced
this pull request
Sep 25, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <[email protected]>
Member
|
Can you sign the CLA? |
mvanhorn
added a commit
to mvanhorn/ax
that referenced
this pull request
Sep 25, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <[email protected]>
ax apply accepted any metadata.name, but Substrate requires actor, ActorTemplate and atespace names to be lowercase RFC 1123 labels. A name such as Task-With-Caps was therefore stored, and only failed seconds later with an asynchronous ActorCreationFailed condition that the user had to dig out of ax describe or the controller logs. Validate metadata.name (and metadata.atespace when set) against [a-z0-9]([-a-z0-9]*[a-z0-9])? with a 63 character limit for Task, Workspace and Model alike, and return InvalidArgument at apply time. Fixes google#370 Co-authored-by: Matt Van Horn <[email protected]>
mvanhorn
force-pushed
the
cursor/validate-resource-names-dfaf
branch
from
September 25, 2026 14:52
06fe19f to
46a5012
Compare
Contributor
Author
Contributor
Author
|
Thanks for the merge @rakyll! |
mvanhorn
added a commit
to mvanhorn/ax
that referenced
this pull request
Oct 14, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <[email protected]>
mvanhorn
added a commit
to mvanhorn/ax
that referenced
this pull request
Oct 15, 2026
Keeps the test valid alongside metadata.name validation (google#406). Co-authored-by: Matt Van Horn <[email protected]>
mayawang
pushed a commit
that referenced
this pull request
Oct 19, 2026
* feat(controller): apply Task resource limits to the ActorTemplate
TaskSpec.resources is documented and accepted by ax-server, but the
controller never read it, so spec.resources.limits had no effect on the
sandbox. Translate limits.cpu and limits.memory into the Substrate
ActorTemplate resources block (Substrate's {name, quantity} list) when
provisioning the per-task template.
Substrate sizes sandboxes by limits only, so requests are documented as
not applied. A limits change already yields a new template because the
launch spec is part of the template digest via AX_TASK_YAML; a test now
pins that behaviour.
Fixes #369
Co-authored-by: Matt Van Horn <[email protected]>
* controller: validate resource limits and never fall back without them
Address review on #405:
- Validate spec.resources before provisioning, at apply time via
ValidateTask and again in the reconciler. Quantities follow the
Kubernetes quantity grammar, must be greater than zero, and the cpu
limit must be below 1000 cores, matching what Substrate enforces on the
ActorTemplate. Invalid values fail the reconcile with Ready=False,
reason InvalidResources.
- When a task has limits and Substrate rejects the per-task template,
fail the reconcile (reason TemplateCreationFailed) instead of falling
back to the default template, which would run the task without the
limits it asked for. Tasks without limits keep the existing fallback.
- Reject spec.resources.requests with a clear message: Substrate sizes
sandboxes by limits alone, so accepting and ignoring it was misleading.
The docs and examples/task.yaml drop the requests block.
- Tests: failure paths for invalid limits and for a rejected template
with and without limits, plus an explicit assertion that a limits
change yields a differently named template.
Co-authored-by: Matt Van Horn <[email protected]>
* test: name the ValidateTask fixtures in TestValidateResources
Keeps the test valid alongside metadata.name validation (#406).
Co-authored-by: Matt Van Horn <[email protected]>
* v1alpha1: follow the ResourceReqs to ResourcesSpec rename
#485 renamed ResourceReqs to ResourcesSpec, so this branch no longer
built against main (pkg/apis/v1alpha1/resources.go:40). Use the new name
in ValidateResources, substrate.ResourceLimits, and their tests.
---------
Co-authored-by: Matt Van Horn <[email protected]>
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.
ax applyaccepted anymetadata.name. Names were only checked when the controller created the SubstrateActorTemplate/Actor, which require a lowercase RFC 1123 label, soTask-With-Capswas stored and then failed seconds later with a confusingActorCreationFailedcondition (and the template error before it is swallowed as a WARN, see #366). This moves the check to apply time.Fixes #370
What changed
pkg/apis/v1alpha1:ValidateName(^[a-z0-9]([-a-z0-9]*[a-z0-9])?$, at most 63 characters, matching Substrate'sk8s-short-name) andValidateObjectMeta, which checksmetadata.nameand, when set,metadata.atespace(it becomes a Substrate atespace name too; empty still defaults todefaultin the server).ValidateTasknow runs it first; newValidateWorkspace/ValidateModeldo the same for the other kinds.internal/server:UpdateWorkspaceandUpdateModelcall the new validators and returnInvalidArgument.UpdateTaskalready goes throughValidateTask, so it needed no change (this also keeps the diff out of the way of Replace UpdateTask with CreateTask and enforce immutability #398).docs/manifests.md: one paragraph on the naming rule.The error is phrased so it is actionable straight from the CLI:
Notes for review:
default/. The shipped examples anddemo.shall use valid names.<task>-tmpl-<8 hex>, so a task name longer than 49 characters still produces a template name over 63. If you'd like, I can cap task names at 49 in a follow-up.How tested
go test ./...(green),go vet ./...,go mod tidyleavesgo.mod/go.sumunchanged.TestValidateName(valid / invalid table incl. 63 vs 64 chars, uppercase,_,., leading / trailing-, whitespace, unicode),TestValidateObjectMeta(name and atespace cases, all three kinds), andinternal/serverTestUpdate_RejectsInvalidNames(Task / Workspace / Model returnInvalidArgument, nothing is persisted, valid names still save). The existingTestValidateTaskfixtures just gained a name.axandax-serverfrom this branch, ranax-serveragainst a local Redis, and applied manifests with an uppercase task name, an underscore workspace name, a dotted atespace, and a valid name (first screenshot).Evidence
Demo
Full-resolution MP4