[Bugfix]: Authenticate worker health checks - #225
Open
StevenWang-CY wants to merge 1 commit into
Open
Conversation
Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
Author
|
@Prowindy, could you review and approve this fix for #159? It propagates the configured worker bearer token through startup readiness, direct and registered health forwarding, and recurring BasicWorker checks, while preserving unauthenticated defaults and redacting the credential from Debug output. DCO and Buildkite are green; local validation passed formatting, Clippy with warnings denied, 489 library and binary tests, and 180 integration tests. I will address any findings promptly. |
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.
Purpose
Fixes #159.
--api-keyis defined as the credential used to authorize requests to workers. The regular router did not attach it to worker health requests. An authenticated worker therefore returned 401 during the startup gate, causing the router to time out before becoming ready. Health checks issued after registration had the same omission and could later mark the worker unhealthy.This change applies the configured bearer token to every regular-router health path:
BasicWorker, including DP-aware workers.Workers remain unauthenticated by default, and the existing public
wait_for_healthy_workerssignature retains its behavior. The credential is held in a private field and omitted from the worker's customDebugoutput.Test Plan
The regression tests run an in-process Axum worker whose
/healthendpoint accepts only the exact configured bearer token. They cover initial startup, invalid-key rejection, direct health forwarding, dynamic registration, credential retention for recurring checks, and secret redaction. Existing tests continue to cover workers without authentication and DP-aware URL handling.Test Result
On the unmodified
maincommit, the authenticated-startup regression timed out waiting for the local worker. With this change, all local validation passed on macOS arm64 with Rust 1.95.0, matching the compiler version in Buildkite:cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test --lib --bins: 489 passedcargo test --test '*': 180 passedpre-commit run --files src/core/worker.rs src/routers/http/router.rs