Skip to content

Remove ReasonSubstrateUnavailable: return Substrate failures as errors, not as state #695

Done

Description

@rakyll

ReasonSubstrateUnavailable is a condition reason that records, as task or workspace state, that a call to Agent Substrate failed. A Substrate outage is not a state of the task. It should be returned as an error to the caller that hit it and not stored. pkg/apis/v1alpha1/types.go already has a TODO saying so.

Where it is used on main

  • Provisioning (internal/controller/reconciler.go): ensureSubstrateResources, bindGateway, and Resume set Ready=False/SubstrateUnavailable and then return the error. recordFailure in internal/server/server.go stores that condition with state QUEUED and returns Unavailable. The caller already gets the error; the stored condition only repeats it for a later ax describe.
  • Workspace prepare (internal/controller/workspace.go): SetupComplete and SnapshotReady are set to False/SubstrateUnavailable, and the error is returned as well.
  • Reading a task (internal/server/server.go): when the task's actor cannot be read, the task is returned with Ready=Unknown/SubstrateUnavailable instead of an error. This is the only place where the reason replaces an error.

Proposed change

  • Return the error in the provisioning and workspace paths without setting the condition. Whether the task is QUEUED and the RPC returns Unavailable already follows from substrate.IsTransientError, not from the condition.
  • Decide what reading a task does when Substrate cannot be reached: fail the RPC, or return the stored task without live actor status. Failing makes ax get and ax describe unusable during a Substrate outage, so this needs a decision before the reason can be deleted.
  • Delete ReasonSubstrateUnavailable and update the tests in internal/controller and internal/server that assert on it.

Related

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions