Skip to content

server: simplify CreateTask retries and model handlers - #748

Merged
rakyll merged 2 commits into
mainfrom
taskSpecMatchesExisting
Nov 24, 2026
Merged

rakyll merged 2 commits into
mainfrom
taskSpecMatchesExisting

Conversation

@rakyll

@rakyll rakyll commented Nov 24, 2026

Copy link
Copy Markdown
Member

Fixes #744. Fixes #718.

  • CreateTask drops taskSpecMatchesExisting. A retry of a Queued task with no template runs the stored task and ignores the incoming spec, because the actor may already exist from the stored spec (TaskManager.Suspend restores the previous status when SuspendActor fails). Re-applying a Queued task with a different spec used to fail with FailedPrecondition; it now retries the stored task. Already provisioned tasks are still rejected as immutable.
  • UpdateModel and DeleteModel no longer take the model lock. A Model has no Substrate side effects, and UpdateModel read the existing metadata before taking the lock anyway.
  • DeleteModel no longer reads the model before deleting it. The store's DeleteModel (memory and Postgres) now returns store.ErrNotFound when nothing is deleted, which the handler maps to NotFound. Deleting tasks, workspaces and gateways is unchanged.
  • Tests: step 2 of TestServer_TransientSubstrateUnavailableRecovery checks that a retry keeps the stored spec, and a new TestDeleteModel in both store packages covers deleting a missing model.

make verify, go build, go test ./... and the Postgres store tests (postgres:17-alpine) pass locally.

@rakyll
rakyll requested a review from mayawang as a code owner November 24, 2026 06:31
@rakyll rakyll self-assigned this Nov 24, 2026
@rakyll
rakyll requested a review from yongruilin November 24, 2026 06:31
@rakyll
rakyll added this pull request to stack #751 November 24, 2026 06:43
Comment thread internal/server/server.go Resolved
Fixes #744. Fixes #718.

- CreateTask no longer compares the incoming spec on a Queued retry: the retry runs the stored task, since its actor may already exist from the stored spec.
- UpdateModel and DeleteModel no longer take a lock: a Model has no Substrate side effects to serialize.
- DeleteModel no longer reads the model first: the store's DeleteModel returns ErrNotFound for a missing model.
@rakyll
rakyll force-pushed the taskSpecMatchesExisting branch from b20abfa to fe66512 Compare November 24, 2026 21:01
Keep rejecting CreateTask retries of a Queued task whose incoming spec
differs from the stored spec, rather than silently running the stored
spec. Removing the retry path altogether belongs with #698.
@rakyll
rakyll merged commit e97bf7a into main Nov 24, 2026
11 checks passed
@rakyll
rakyll deleted the taskSpecMatchesExisting branch November 24, 2026 21:13
rakyll added a commit that referenced this pull request Nov 24, 2026
Part of #749: the bugs and the duplication. The small things are left
for a follow-up. Stacked on #748; once it merges, this PR retargets to
`main`.

## Bugs

- `-template` and `-template-atespace` are removed: `TaskManager` stored
them but never read them. This also removes them from `NewTaskManager`,
the `deploy/ax-server.yaml` args, the namespace rewrite in
`deploy/embed.go`, and `test/e2e/manifests/ax-server.yaml`. A new
`ax-server` started with an old manifest that still passes `--template`
fails with "flag provided but not defined"; manifests rendered by the
matching CLI are fine.
- `UpdateModel` treats only `store.ErrNotFound` as a new model. Before,
any store error gave an existing model a new uid and createTime.
`TestUpdateModel_StoreError` covers it.
- `recordFailure` logs a failed status write instead of ignoring it.

## Duplication

- `lockStoredTask` replaces the lock, load, and NotFound/Internal
mapping copied into `DeleteTask`, `SuspendTask`, and `ResumeTask`.
- `substrateError` maps a Substrate error to `Unavailable` (transient)
or `Internal` for `SuspendTask`, `recordFailure`, and `DeleteWorkspace`.
`deleteTask` (passes Substrate's gRPC codes through) and
`prepareWorkspace` (`FailedPrecondition` with the setup error) keep
their own mapping.
- `defaultMetadata(meta, prev)` takes the stored metadata instead of a
callback.
- `atespaceOrDefault` replaces the repeated defaulting, including the
three hard-coded `"default"` in `gateway.go`.
- The List handlers read the request with nil-safe getters.

`DeleteGateway` still reads the gateway before deleting it; the store is
unchanged.

`make verify`, `go build`, and `go test ./...` pass locally. The E2E and
local install tiers were not run.
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.

server: taskSpecMatchesExisting is not needed server: don't lock models in ApplyModel and DeleteModel

2 participants