fix(spartan): keep prover agents alive while proving jobs are in flight - #25232
Draft
AztecBot wants to merge 1 commit into
Draft
fix(spartan): keep prover agents alive while proving jobs are in flight#25232AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
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.
What
Adds a third KEDA trigger to the prover-agent
ScaledObjectthat holds one replica per in-progress proving job, so the agent pool is never scaled down (or deactivated to zero) while proofs are actually running.Why
Testnet epoch 1274 failed to prove today and the chain was pruned back to checkpoint 37924 / block 42512 at 13:24:25 UTC, un-mining 21 txs and taking the in-progress epoch 1275 with it.
The root cause is that the ScaledObject scales purely on pending queue depth:
ProvingBroker.measureQueueDepthreturnsthis.queues[type].length()— the pending queue only. As soon as the broker hands a job to an agent it moves tothis.inProgressand drops out of that metric (yarn-project/prover-client/src/proving_broker/proving_broker.ts:174). So a fully-busy agent pool reports a queue depth of zero, every band evaluates to 0, and withactivationThreshold: "0"KEDA deactivates the deployment to zero replicas and SIGTERMs agents that are mid-proof.Job
1274:PUBLIC_TX_BASE_ROLLUP:50628bb6…was killed this way three times in 2m20s, exhausting its retry budget:q27ptShutting down...→ job abortedk5n7kKilling→ job aborted729kpKEDAScaleTargetDeactivated: from 4 to 0→ job abortedtimed out after 3 attempts. Marking as failed.Error in EpochSession …: Sub-tree for checkpoint 6 failed: Error: Timed out— epoch 1274 top tree cancelledDetected epoch prune to 37924;Chain pruned to block 42512Every attempt produced its witness in under 3 seconds and was then terminated, so the ~30s broker job timeout was never the binding constraint — pod termination was. Across the 2-hour window the deployment hit zero replicas 26 times (
4 → 0and8 → 0), roughly every 6–7 minutes.How it works
KEDA takes the largest desired replica count across triggers, and only deactivates a ScaledObject to zero when every trigger is inactive. With
threshold: "1"the new trigger asks for exactlyactive_jobsreplicas, so it acts purely as a floor:The existing band triggers are unchanged and stay driven by pending queue depth, so the tuning in each environment's
PROVER_AGENT_KEDA_SCALING_BANDSkeeps its current meaning. The new trigger is appended last so the band triggers keep their currents0-prometheus,s1-prometheus, … indices.aztec_proving_queue_active_jobs_countis the existingPROVING_QUEUE_ACTIVE_JOBSobservable gauge fromProvingBrokerInstrumentation, countingthis.inProgress. It is already scraped and plotted in the prover dashboard with the same label selector (spartan/metrics/grafana/dashboards/aztec_provers.json:508), so no new instrumentation or metrics-whitelist change is needed. Theor vector(0)guard matches the existing band queries and keeps the expression defined when the series is absent.The floor assumes one concurrent job per agent pod (
PROVER_AGENT_COUNT=1, the default and what testnet runs). With a higher agent count per pod it over-provisions rather than under-provisions, which is the safe direction; a comment in the template records this.Testing
helm templaterendered against a testnet-shaped release and against the no-bands fallback path; output parsed with a YAML loader and triggers inspected. Both branches of the template render validScaledObjects and the band trigger indices are unchanged:There is no unit-test harness for these chart templates, so this was not covered by an automated red/green test.
Not covered here
This stops KEDA from choosing to kill a busy agent. It does not make agent shutdown itself graceful — the agent still aborts its job in the same millisecond it receives SIGTERM (
Shutting down...andAborted job controller for jobId=…share a timestamp), so any other eviction (node drain, rollout, preemption) still loses in-flight work. Draining properly needs an app-side change in the proving agent plus a matchingterminationGracePeriodSeconds; a longer grace period alone would do nothing while the process aborts on the first signal. Worth doing as a follow-up.Full log analysis: https://gist.github.com/AztecBot/545c97fe180ff1bcf32bfd2a41453499
Created by claudebox · group:
slackbot· requested by Alex Gherghisan · Slack thread