Repository navigation
controller,substrate: handle transient Substrate unavailability without permanent Task failure - #463
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
mayawang
left a comment
There was a problem hiding this comment.
Thanks @aprajitaarora13, the problem write-up and the recovery test made this easy to follow, and treating Unavailable as transient is right. #468 sets out how this fits with #457 and #465; easiest to rebase once those two land.
| _, err = s.store.GetTask(ctx, atespace, taskName) | ||
| if err == nil { | ||
| existing, err := s.store.GetTask(ctx, atespace, taskName) | ||
| if err == nil && existing.GetStatus().GetPhase() != "Pending" { |
There was a problem hiding this comment.
This accepts a re-apply of a Pending task with any spec, which reopens the immutability from #398. Could it only accept an unchanged spec?
There was a problem hiding this comment.
Good catch — updated CreateTask to require proto.Equal(existing.GetSpec(), task.GetSpec()) (and preserve CreationTimestamp) when re-applying a Pending task, returning codes.FailedPrecondition if the spec differs. Added a test case in TestServer_TransientSubstrateUnavailableRecovery to verify.
| return task, nil | ||
| } | ||
|
|
||
| func isTransientError(err error) bool { |
There was a problem hiding this comment.
This and isTransientSubstrateError in the reconciler are the same check. One helper in internal/substrate would keep them from drifting.
There was a problem hiding this comment.
Done — consolidated both helpers into substrate.IsTransientError in internal/substrate/client.go with unit tests in internal/substrate/client_test.go.
|
What's the recovery from these transient errors looks like? I don't see any retries in this PR. If there is no easy way to recover, it's better to fail the task creation and asking the client to retry it. |
|
Update: #465 is closed (AX won't run its own queue, see #367), so please ignore my earlier note about using its loop. Your original approach of keeping the task Pending and returning Unavailable is the right shape. Remaining asks are in the updated #468: rebase after #457, reuse its retry helper, and keep re-apply limited to an unchanged spec. |
0c7d7d5 to
3eb65c2
Compare
|
@rakyll @mayawang Thanks for the reviews! Rebased onto
|
3eb65c2 to
8653e7e
Compare
mayawang
left a comment
There was a problem hiding this comment.
Thanks @aprajitaarora13, this lines up with #468 exactly, and dropping the dial-level changes made it simpler too. Tests pass on main with #457 and #464 in. Approving, go ahead and merge.
One follow-up, non-blocking: a single Substrate call can now retry Unavailable for up to ~20s, and the task lock is a fixed 30s with no renewal. If Substrate flaps mid-request, a reconcile could outlast the lock. A per-request deadline under the lock TTL would cover it. Could you open an issue for that?
|
+1 to @rich7420's suggestion. Once the spec check passes, saving the stored task keeps a re-apply from overwriting status with client-supplied values. Could you take it, with a test? I'll re-approve after. |
…ut permanent Task failure When the Substrate control plane is briefly unavailable (e.g. during ateapi rollout or cold connection establishment), the controller previously marked the Task as Phase: Failed permanently without retrying or distinguishing transient transport errors from permanent actor errors. - Add codes.Unavailable to retryOnCodes across Substrate client RPCs in internal/substrate/client.go and export substrate.IsTransientError. - Classify gRPC Unavailable and DeadlineExceeded errors in the TaskReconciler as transient: keep Task.Status.Phase in Pending with condition Ready=False (Reason: SubstrateUnavailable) rather than permanently setting Phase: Failed. - Preserve Pending status and SubstrateUnavailable condition in CreateTask and ResumeTask when direct reconciliation hits a transient Substrate error, return codes.Unavailable to callers, and allow CreateTask to retry reconciliation on an existing Pending task only when the spec is unchanged. Fixes google#421
1edb34d to
d34865d
Compare
|
@mayawang @rich7420 Updated |
Fixes #421
Problem
When the Substrate control plane (
ateapi) is briefly unavailable (for example during a pod rollout or initial connection establishment),EnsureAtespace,EnsureActor, orResumeActorfails immediately withUnavailableorDeadlineExceeded, andTaskReconciler.Reconcilepermanently marks the Task asPhase: Failed. In addition,CreateTaskandResumeTaskoverwriteTask.Status.PhasetoFailed, leaving no way forax applyorax resumeto recover the task once Substrate is reachable again.Changes
internal/substrate/client.go:grpc.WithDefaultCallOptions(grpc.WaitForReady(true))andgrpc.WithConnectParams(BaseDelay: 100ms,MaxDelay: 5s,MinConnectTimeout: 1s) on bothNewClientWithOptionsandNewClient.callContext(DefaultCallTimeout = 10s) when the caller's context does not carry a deadline soWaitForReady(true)waits through brief connection drops without blocking indefinitely.internal/controller/reconciler.go:codes.Unavailable,codes.DeadlineExceeded, andcontext.DeadlineExceededas transient viaisTransientSubstrateError.EnsureAtespace,EnsureActor, orResumeActorfails with a transient Substrate error, keeptask.Status.Phase = "Pending"and record conditionReady=False (Reason: SubstrateUnavailable)instead of transitioning toPhase: "Failed".internal/server/server.go:reconciled.Status(Phase: "Pending"andSubstrateUnavailablecondition) on transient Substrate errors inCreateTaskandResumeTask, and returncodes.Unavailableto callers.CreateTaskto re-run reconciliation when an existing task is still inPhase == "Pending".internal/substrate/client_test.go:TestClient_WaitForReady_WaitsForLateServerandTestClient_WaitForReady_HonorsCallTimeout.internal/controller/reconciler_test.go:TestTaskReconciler_TransientSubstrateUnavailable.internal/server/server_test.go:TestServer_TransientSubstrateUnavailableRecovery.