Skip to content

feat(server): export supervisor session placement metrics - #4692

Open
EmilienM wants to merge 2 commits into
NVIDIA:mainfrom
EmilienM:feat/4688-placement-metrics/EmilienM
Open

EmilienM wants to merge 2 commits into
NVIDIA:mainfrom
EmilienM:feat/4688-placement-metrics/EmilienM

Conversation

@EmilienM

@EmilienM EmilienM commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds placement metrics for consistent-hash session placement (#3661), scoped to the topologies where each signal is honest: redirects and ring size everywhere, off-ring admissions only where the gateway itself places sessions by ring.

Related Issue

Closes #4688
Part of #4223

#4688 still needs state:accepted for the acceptance check.

Changes

  • openshell_server_supervisor_session_redirects_total{reason} counts each SessionRedirect a replica sends, connect when it answers a connecting supervisor and shutdown when a stopping replica queues a handoff. A handoff that can't be queued doesn't count.
  • openshell_server_supervisor_session_off_ring_admissions_total counts redirected supervisors admitted although this replica's ring names another owner, recorded once the session's acceptance is durable. It exists only on gateways that place supervisor sessions by ring: under supervisor_topology: gateway (feat(server): keep pool sandbox sessions on their supervisor's gateway #5052) the shared supervisor's host moves sessions, a redirected hello is the designed state, and the series is neither exported nor counted. Dashboards that alert on it should tolerate its absence on pool gateways.
  • openshell_server_gateway_ring_members reports the replicas in this replica's ring. Every ring write goes through one helper that records it under the same lock, and only replicas that join the ring export it.
  • Docs: the metrics catalog and the HA guide's Monitor Capacity row say what the counters cannot see under the shared topology (host-driven moves, shutdown counts as a lower bound), and the debug skill greps the series.

Testing

  • mise run rust:lint, mise run rust:format:check, cargo test -p openshell-server --features test-support (2664 passed), mise run test:rust:postgres (40 passed), mise run markdown:lint, mise run docs:build:strict pass locally. Pool-regime tests install a SupervisorHostController and assert the record and init paths stay silent; the PostgreSQL tests drive a real connect redirect and the membership worker.
  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

@copy-pr-bot

copy-pr-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request has had no activity for 14 days and is now marked stale.

@github-actions github-actions Bot added the state:stale Inactive item at risk of automatic closure. label Nov 2, 2026
@EmilienM
EmilienM force-pushed the feat/4688-placement-metrics/EmilienM branch from 9328dc9 to 6af3db2 Compare November 2, 2026 20:49
@github-actions github-actions Bot removed the state:stale Inactive item at risk of automatic closure. label Nov 3, 2026
@FrostGod

FrostGod commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 6af3db2

@FrostGod

FrostGod commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

These PR needs changes with the tree topology design and shared supervisor logic we have, please think through it, happy to discuss over a call

@mrunalp mrunalp added area:gateway Gateway server and control-plane work test:e2e-kubernetes Requires Kubernetes end-to-end coverage labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Label test:e2e-kubernetes applied for 6af3db2. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute Kubernetes HA and credential-driver E2E after building the required gateway, sandbox, and supervisor images once. This is an optional proof-of-life suite; failures are visible in the workflow run but do not publish a required CI gate status.

@mrunalp

mrunalp commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 6af3db2

Consistent-hash placement only logged its redirects, so operators had
no way to see how often replicas redirect supervisors or whether
supervisors end up where the ring places them.

The gateway now counts each SessionRedirect it sends, labeled by the
step that sent it: connect when it answers a connecting supervisor, or
shutdown once a stopping replica has queued a handoff on an open
session. It also counts redirected supervisors it admits although its
own ring names another owner, once the session's acceptance is durable,
so a cancelled connect cannot lose the count.

Under supervisor_topology: gateway the shared supervisor's host moves
pool sessions itself, so a redirected hello there is the designed
state, not ring disagreement. Those gateways export no off-ring series
at all and never read the ring on the connect path. Both counters
start at zero and carry no sandbox or replica IDs. The gateway metrics
page, the HA guide, and the debug skill document what the counters
cannot see under the shared topology.

Signed-off-by: Emilien Macchi <emacchi@redhat.com>
Each replica builds its placement ring from live membership, but
nothing showed how many replicas a given replica had in its ring, so a
replica that dropped out of its peers' rings, or a ring cleared after
failed refreshes, went unnoticed.

openshell_server_gateway_ring_members now reports the replicas in this
replica's ring. Every ring write goes through one helper that records
the size under the same lock: the periodic refresh, leaving the ring at
shutdown, and clearing a stale ring. Only replicas that join the ring
export the gauge, so SQLite gateways and replicas without a peer
endpoint show no series rather than a misleading 0.

The HA guide's Monitor Capacity table gains a Session placement row
scoped to gateways that place supervisor sessions by ring: under the
multi-tenant topology the shared supervisor's host moves sessions, and
that section says the placement metrics do not reflect those moves.

Part of NVIDIA#4223
Closes NVIDIA#4688

Signed-off-by: Emilien Macchi <emacchi@redhat.com>
@EmilienM
EmilienM force-pushed the feat/4688-placement-metrics/EmilienM branch from 6af3db2 to 5e82f09 Compare November 4, 2026 18:39
@EmilienM

EmilienM commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thought it through against #5052 and RFC 0018 rather than waiting for a call.

Redirects and ring size are unchanged: they count gateway actions that hold in both regimes. The off-ring counter is the one that wasn't honest under the tree, so it now exists only on gateways that place supervisor sessions by ring. Under supervisor_topology: gateway the series isn't exported at all (the startup init path is gated too), because a redirected hello there is the host following its design, not ring disagreement. The docs now say host-driven moves never appear in redirects_total, and shutdown counts are a lower bound for pool sessions.

I left preferred_peer_redirect pool-aware out on purpose: #5052 dropped gateway-side pool placement, so I took that as the boundary you want. The one edge I found is a pool session hostless for more than 5 seconds getting ring-redirected away from where its host reattaches. Happy to file a narrow issue for it if you want to weigh in.

@FrostGod

FrostGod commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 5e82f09

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gateway Gateway server and control-plane work test:e2e-kubernetes Requires Kubernetes end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(server): export supervisor session placement metrics

3 participants