/operation/cordoning.llms.txt
Cordoning
When a vendor starts acting up — latency spikes, wrong responses, a quota incident — you want it gone from routing right now, not after a 15-minute error-rate window closes. One admin RPC call cordons the upstream instantly. Another call brings it back just as fast. No config change, no redeploy, no restart.
Agent reference
Copy one of these prompts into your AI agent session (Claude Code, Cursor, …) — each one points the agent at this page's machine-readable reference so it can do the work correctly:
Prompt Example #1: pull a degraded upstream out of rotation right now
One of my eRPC upstreams is having a vendor incident and I need to remove it from routing immediately without redeploying. Show me the admin API calls to cordon it, verify the change, and restore it when the incident is resolved. My admin endpoint is configured in my eRPC config. Read the full reference first: https://docs.erpc.cloud/operation/cordoning.llms.txt
Prompt Example #2: cordon a single broken RPC method
A specific upstream in my eRPC setup is timing out only on eth_getLogs but is fine for everything else. Show me how to cordon just that method without pulling the whole upstream out of rotation, and explain why erpc_listCordoned won't show it. Work with my existing eRPC config. Reference: https://docs.erpc.cloud/operation/cordoning.llms.txt
Prompt Example #3: alert and dashboard on cordon state
Set up Prometheus alerts and dashboard panels so I can see which eRPC upstreams are currently cordoned, how long they've been cordoned, and how many times they've been cordoned in the past 24 hours. Explain the erpc_upstream_cordoned gauge vs the event counter. Reference: https://docs.erpc.cloud/operation/cordoning.llms.txt
Cordoning — full agent referenceExpand for every option, default, and edge case — or copy this entire section into your AI assistant.
How it works
Two kinds of cordon exist and they never overwrite each other:
- Operator cordons (
erpc_cordonUpstreamwithmethod: "*", the default) are one shared counter per upstream — the same primitive that shares block heights across pods. Key<clusterKey>/v2/operatorCordon/<projectId>/<upstreamId>/<hash>, value = unix-ms when cordoned,0when lifted. Shared state does the rest: pub/sub propagation onredis/postgresql(milliseconds), background reconcile ondynamodb(seconds), and an initial fetch when the upstream bootstraps, so a restarted or scaled-out pod restores the cordon before it serves anything. Writes are local-first and pushed in the background, like every other shared counter; if the store is unreachable the cordon applies on this pod and reaches peers when the store returns. With thememorydriver (the default whendatabase.sharedStateis omitted) the counter is in-process only. - Automatic cordons are set by in-process detectors (consensus sit-out, SVM health,
EVM chain-identity mismatch) on the health tracker's
(upstream, method, finality=All)cell, as are method-scoped operator cordons (method: "eth_getLogs"). They are per pod. While the shared operator cordon is held, a detector cannot lift the"*"cell — a consensus penalty ending never releases an operator cordon.
Routing, erpc_listCordoned and the health check all read one lookup,
Tracker.CordonedReason(upstream, method): the wildcard "*" cell first, then the
method cell. The policy reads it per upstream rather than from the slot's metrics bucket,
so a wildcard cordon shadows every method slot at every selection-policy evalScope.
The state feeds the selection policy through the cordonedReason field exposed on each
upstream's JS metrics object. The built-in default policy calls .removeCordoned() as its
first chain step, so a cordon takes effect within one eval interval (default 15 s) after
it reaches a replica. A custom evalFunc must call .removeCordoned() explicitly or the
cordon has no routing effect.
erpc_uncordonUpstream lifts the shared operator cordon for the whole fleet and
clears every cordon class on "*" (operator, punishment, and availability).
That is the operator recovery path for any wildcard cordon. Availability cordons
also clear automatically when their owner recovers: the EVM state poller lifts
its own bit after a later major-move eth_chainId verify matches again, and
the SVM state poller lifts when state probes answer again and shred-insert lag recovers.
Method-scoped Uncordon still clears only the requested class bit (feature §4.5).
Uncordoning a method never lifts a wildcard cordon.
Behavior changes (upgrade note)
- One cordon bit per source. Previously a single flag was shared across operator,
consensus-sit-out (punishment), and detector (availability) sources, so one
Uncordoncould clear an unrelated cordon. Now each source holds its own bit and clears only its own; a sit-out ending never releases an operator cordon. - The chain-identity cordon is an
availabilitycordon and expires. While it holds, every head the upstream reports is dropped. The poller checkseth_chainIdevery 5 minutes and lifts it after 2 matches in a row, the only way out: an admin uncordon restores routing but not its heads, and a mismatch cordons it again. - A full
erpc_uncordonUpstreamalso resets consensus sit-out state, so the upstream can be re-punished immediately instead of waiting for the original penalty window to end.
The reason string is kept only on the replica that took the call; peers and restarted
pods report "operator cordon (set on another replica)". Re-cordoning an already
cordoned upstream keeps the original start, whichever replica serves it, so
erpc_upstream_cordon_duration_seconds measures the whole incident.
Use cordons for outages measured in minutes to days. For permanent exclusion, remove the
upstream from config or set ignoreMethods: ["*"] and redeploy.
Config schema
Cordoning has no config-file fields. It is controlled entirely at runtime via admin RPC.
The selection policy's evalFunc implicitly controls whether cordon state is respected —
it requires .removeCordoned() in the chain. For evalFunc and evalInterval config
fields, see Selection & scoring.
Worked examples
1. Incident response: cordon a vendor immediately.
You notice erpc_upstream_error_rate spiking on alchemy-eth-1 before the error window
is wide enough to trigger automatic exclusion. Cordon it now:
curl -X POST http://localhost:4000/admin \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0", "id": 1,
"method": "erpc_cordonUpstream",
"params": [{"projectId": "main", "upstream": "alchemy-eth-1",
"reason": "vendor incident #12345"}]
}'{"jsonrpc":"2.0","id":1,"result":{
"projectId": "main",
"upstream": "alchemy-eth-1",
"method": "*",
"cordoned": true,
"reason": "vendor incident #12345"
}}Omitting method cordons the upstream for all methods ("*").
2. Method-scoped cordon: isolate a broken RPC method.
A vendor is fine for most calls but eth_getLogs is timing out past 30 s. Cordon just
that method while the rest of the vendor's capacity keeps working:
curl -X POST http://localhost:4000/admin \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0", "id": 2,
"method": "erpc_cordonUpstream",
"params": [{"projectId": "main", "upstream": "drpc-eth-1",
"method": "eth_getLogs", "reason": "p95 > 30 s"}]
}'A wildcard cordon overrides method-scoped cordons: an upstream with both "*" and
"eth_getLogs" cordons is excluded for all methods. Uncordoning a specific method does
not lift a wildcard cordon.
3. List and restore. During an incident, list all whole-upstream cordons, then restore when the vendor confirms recovery:
# list whole-upstream cordons in a project
curl -X POST http://localhost:4000/admin \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":3,"method":"erpc_listCordoned",
"params":[{"projectId":"main"}]}'{
"projectId": "main",
"cordoned": [
{"upstream": "alchemy-eth-1", "reason": "vendor incident #12345"}
]
}erpc_listCordoned only returns upstreams with a "*"-scope cordon (operator or
automatic). Method-scoped cordons are invisible to it; read the erpc_upstream_cordoned
gauge labels to enumerate them.
# restore the upstream
curl -X POST http://localhost:4000/admin \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":4,"method":"erpc_uncordonUpstream",
"params":[{"projectId":"main","upstream":"alchemy-eth-1",
"reason":"vendor confirmed resolved"}]}'4. Custom evalFunc — explicit .removeCordoned() required.
If you have replaced selectionPolicy.evalFunc with a custom function, you must call
.removeCordoned() explicitly near the start of the chain. Without it the
cordonedReason field on the upstream's metrics object is populated, but no step actually
drops the upstream from the ordered list — the cordon has no routing effect.
Source: internal/policy/default_policy.js:L1 — .removeCordoned() is the first call.
Request/response behavior
erpc_cordonUpstreammethodparam defaults to"*"when absent;reasondefaults to"admin: manual cordon"."*"sets the shared operator cordon; any other method sets a cordon on this replica only. [erpc/admin.go:L656-694]erpc_uncordonUpstreamreasondefaults to"admin: manual uncordon"— a distinct string from the cordon default; it is used only for the local automatic cordon it lifts.erpc_listCordonedonly returns upstreams whereCordonedReason("*")returnscordoned=true— method-scoped cordons are not listed.- Routing changes on the next policy eval tick (default 15 s) after the cordon reaches a
replica; shared-state propagation to peers is milliseconds on
redis/postgresqland seconds ondynamodb. - A cordoned upstream is placed at position
-1inerpc_selection_positiononce.removeCordoned()drops it. - All admin RPCs require
admin.authconfigured; missingadmin:block returns"admin is not enabled for this project"(401); presentadmin:but absentadmin.auth:returns"admin auth not configured"(401). [erpc/admin.go:L26-30]
Best practices
- Cordon early, not late. The selection policy's metric-driven exclusion needs sample
accumulation; cordoning is zero-lag. When you see a vendor degrading in dashboards,
cordon it immediately rather than waiting for
errorRateAbove(0.7)to trigger. - Always supply a reason string. The reason appears in
erpc_upstream_cordonedgauge labels and inerpc_listCordonedoutput. A reason like"incident-#12345 alchemy"makes incident timelines clear and helps correlate with duration histograms post-incident. - Prefer method-scoped cordons when feasible. If a vendor is broken only for
eth_getLogsbut healthy foreth_call, a method-scoped cordon keeps the vendor in rotation for the methods it can serve — reducing pressure on remaining upstreams. - Remember the 15 s propagation delay. The tracker is updated immediately, but the ordered-list cache is rebuilt on the next eval tick. Build runbooks around this delay (e.g. wait 20 s before verifying traffic shifted).
- Use a remote
database.sharedStateconnector for fleets. Operator cordons reach every replica and survive restarts only throughredis,postgresqlordynamodb;memorykeeps them in-process. - Do not use cordon for permanent exclusions. For a vendor you want permanently removed, update the config; a shared cordon outlives the pod that set it.
- Custom evalFunc operators:
.removeCordoned()must be explicit. The default policy includes it; a customevalFuncthat omits it will silently ignore all admin cordons.
Edge cases & gotchas
- Uncordoning a method does not lift a wildcard cordon.
IsCordonedchecks the operator cordon and the"*"cell first, so the upstream stays out of rotation for all methods as long as either is active. Source:health/tracker.go:L900-939. - Automatic and method-scoped cordons are per pod; whole-upstream operator cordons are
per fleet. A consensus sit-out, chain-identity cordon or
method: "eth_getLogs"cordon on one replica is not visible on others. Anerpc_uncordonUpstreamfor"*"reaches every replica and clears all cordon classes there (operator + punishment + availability). EVM/SVM availability cordons also clear automatically on their owning poller when the underlying health/identity check recovers. - The reason travels only with the pod that took the call. Peers and restarted pods
show
"operator cordon (set on another replica)"inerpc_listCordonedand in theerpc_upstream_cordonedreasonlabel. - Custom evalFunc without
.removeCordoned()ignores all cordons.cordonedReasonis populated on the JS upstream object, but no routing effect occurs unless.removeCordoned()(or equivalent logic) appears in the chain. - Routing effect is delayed by up to
evalInterval. The tracker is updated immediately, but the ordered-list cache used by the request path is rebuilt on the next eval tick. Requests in flight can still reach the upstream for up to one eval interval. - State-poller is unaffected by cordon. The EVM state poller for a cordoned upstream continues running, keeping its latest/finalized block numbers fresh. When uncordoned, the upstream's metrics are current and re-admission scoring works immediately.
- Shadow mirroring is unaffected by cordon. Shadow upstreams receive async-mirrored traffic regardless of cordon state; cordon only affects routing of real requests.
erpc_cordonUpstreamis idempotent on the same upstream. Repeated calls update the localreasonbut do not reset the shared value or fire multiplecordonevent counter increments, whichever replica serves them. Source:upstream/upstream.go:L1526-1536.- The default policy's
.whenEmpty(() => upstreams)safety net can re-admit a cordoned upstream. If every other upstream is health-excluded (for example far behind the network head), the raw set is used rather than failing closed. erpc_listCordonedrequiresadmin.authconfigured. If theadmin:section is present butadmin.auth:is absent, the request returns"admin auth not configured". If theadmin:section is entirely missing, it returns"admin is not enabled for this project". Both are 401 responses. Source:erpc/admin.go:L26-30.
Observability
| Metric | Type | Labels | When it fires |
|---|---|---|---|
erpc_upstream_cordoned | gauge | project, vendor, network, upstream, category (=method), reason | Set to 1 on cordon, 0 on uncordon; persists until uncordon or process restart |
erpc_upstream_cordon_event_total | counter | project, network, upstream, action | Edge transitions only: OFF→ON (action="cordon") and ON→OFF (action="uncordon"); repeated cordons do not increment |
erpc_upstream_cordon_duration_seconds | histogram | project, network, upstream | Observed once per uncordon on each replica; value = now − CordonedAtMs as seen by that replica; buckets 1 s … 86400 s |
erpc_selection_position{upstream=…} | gauge | project, network, method, upstream | Set to -1 for every excluded (including cordoned) upstream after each eval tick |
erpc_selection_rejection_total{step="removeCordoned"} | counter | project, network, method, upstream, step | Per tick × upstream dropped by the .removeCordoned() step |
Log messages (DEBUG level, health/tracker.go):
"cordoning upstream to disable routing"/"uncordoning upstream to enable routing"— every automatic or method-scopedCordon/Uncordoncall.
Source code entry points
upstream/upstream.go:L1503-1567(opens in a new tab) —CordonAdmin/UncordonAdmin, the shared counter (operatorCordonVar) that flips the"*"cell, and theUncordonguardhealth/tracker.go:L842-939(opens in a new tab) —Cordon/Uncordon,IsCordoned,CordonedReasondata/shared_state_variable.go(opens in a new tab) —CounterInt64SharedVariable: the shared primitive (rollback threshold0accepts every change, including back to0)erpc/admin.go:L590-736(opens in a new tab) —erpc_cordonUpstream,erpc_uncordonUpstream,erpc_listCordonedhandlersinternal/policy/eval.go(opens in a new tab) —cordonedReasonexposed to the JS eval context viaTracker.CordonedReasoninternal/policy/default_policy.js:L1(opens in a new tab) —.removeCordoned()as first default policy step
Related pages
- Admin API — authentication setup required before any cordon call will succeed.
- Selection & scoring — the
evalFuncchain where.removeCordoned()must appear; alsoevalIntervalthat controls propagation delay. - Survive provider outages — the incident-response outcome cordoning helps achieve.
- Upstreams — permanent exclusion via
ignoreMethods: ["*"]or config removal, the alternative when cordon is not the right tool.