Repository navigation
fix(scheduler): authenticate node snapshot pulls with X-API-Key - #552
Open
Pangjiping wants to merge 1 commit into
Open
Pangjiping wants to merge 1 commit into
Pangjiping wants to merge 1 commit into
Conversation
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). |
This branch has not been deployed
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
Send
X-API-Keyinstead ofX-Admin-Tokenwhen the HA scheduler pullsGET /nodesduring post-election state recovery (sync-node-snapshots), and align the HA E2Estubnode, unit tests, and HA documentation with the runtime's actualX-API-Keycontract.Why
Deployed Rust runtime nodes authenticate every protected control-plane endpoint — including
GET /nodes— exclusively withX-API-Key(src/api/impls/auth.rs, enforced byscripts/tests/e2e/suites/08_auth.shand noted indocs/src/stoplight-elements.html).NewAdminSnapshotFetcher(services/scheduler/internal/node_snapshot.go) previously sentX-Admin-Token, andservices/scheduler/e2e/stubnode/main.gomirroredX-Admin-Tokenin the Kind HA E2E double. As a result, E2E passed againststubnodewhile every real failover against Rust runtime nodes failedsync-node-snapshotswith401 Unauthorized, forcing the new leader to wait for periodic gRPC heartbeats before observing node state.Compared with widening the Rust auth middleware to accept a second header alias (#500), switching the scheduler client to
X-API-Keykeeps the single-header control-plane security boundary intact (matchingservices/gateway,08_auth.sh, and proxy header scrubbing) with a minimal, surgical diff.Related issue
Closes #450
Scope and non-goals
NewAdminSnapshotFetcher(services/scheduler/internal/node_snapshot.go) sendsX-API-Key.stubnode(services/scheduler/e2e/stubnode/main.go) checksX-API-Keysoscheduler-ha-e2evalidates the same header real Rust nodes require.services/scheduler/internal/node_snapshot_test.go) verifyX-API-Keyis sent andX-Admin-Tokenis absent.services/shared/config/config.go,services/README.md,deploy/k8s/overlays/ha/README.md) updated to referenceX-API-Key.src/api/impls/auth.rs) or the upstream E2B-compatiblesrc/api/openapi.ymlschema (already normalized toApiKeyAuthin the rendered API reference viadocs/src/stoplight-elements.html).scheduler.node_admin_api_key/SCHEDULER_NODE_ADMIN_API_KEYremain unchanged).Design and behavior changes
GET {node.Endpoint}/nodesrequests now setX-API-Key: <node_admin_api_key>whennode_admin_api_keyis non-empty, matchingsrc/api/impls/auth.rs(require_authandApiKeyAuthHeader).http.ErrUseLastResponse), 5s timeout, 1 MiB body limit, node-ID matching, and freshness guards are unchanged.Compatibility and operations
X-API-KeyonGET /nodes).scheduler.node_admin_api_keyandSCHEDULER_NODE_ADMIN_API_KEYare unchanged and continue to carryAENV_API_KEY).agentenv-scheduler; rolling back reverts to401onsync-node-snapshotswith automatic fallback to 5s heartbeats.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes; see macOS note below)maketargetCommands and results:
Skipped checks and reasons:
make fmt,make clippy,make test-unit) and OpenAPI codegen: No Rust files or OpenAPI schemas were modified; local validation ran on macOS (whereservices/composeTestLoadMatchesDockerComposehas a/varvs./private/varDocker Desktop symlink path difference unrelated toscheduler, covered on Linux inservices-ciandscheduler-ha-e2e).Risks and reviewer notes
services/scheduler/internal/node_snapshot.goandservices/scheduler/e2e/stubnode/main.go.stubnodeis updated in lockstep so thescheduler-ha-e2eKind workflow exercises the exactX-API-Keyheader expected byaenv-server.Checklist