Skip to content

[controller] Add a lightweight controller health endpoint - #3064

Open
kvargha wants to merge 12 commits into
linkedin:mainfrom
kvargha:kvargha/controller-health-endpoint
Open

kvargha wants to merge 12 commits into
linkedin:mainfrom
kvargha:kvargha/controller-health-endpoint

Conversation

@kvargha

@kvargha kvargha commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Problem Statement

The controller API lacks a dedicated readiness endpoint. Health-check clients need a cheap, parameter-free way to distinguish a controller ready to serve API requests from one still starting or shutting down.

Solution

Add GET /health on the existing controller HTTP/HTTPS API service. It returns plain-text 200 OK when initialization completed and the required local services are running; otherwise it returns 503 NOT_READY. Eligible standbys pass without leadership checks; passive parent regions remain unready.

Use one shared atomic signal: NOT_READY, READY, STOPPING. The existing startup sequence stays unchanged, with a ready transition added at its successful end. Startup exceptions leave the signal unready. Shutdown marks stopping before unregistration, and late startup completion cannot restore readiness.

The request reads local state only, with no cluster scan, dependency call or wait. The route is enabled by default and respects existing disabled routes. Only exact GET /health receives the non-sensitive HTTP health exception; other methods and lookalike paths follow normal SSL enforcement. HTTPS client-certificate policy is unchanged.

AdminSparkServer has one constructor requiring an explicit serializer and live readiness callback. Production listeners use the controller owner's callback. The existing ServiceFactory.getMockAdminSparkServer(...) helper provides default serialization and readiness tied to the mock listener's start/stop lifecycle. Exact GET /health probes retain request metrics and failure classification but skip per-request INFO audit logging to avoid repetitive logs from periodic probes. Other methods and paths retain normal auditing.

This checks local API readiness and responsiveness, not every backend operation. No discovery-policy change or deployment is included.

Code changes

  • Added new code behind a config. If so list the config names and their default values in the PR description.
  • Introduced new log lines.
    • Confirmed if logs need to be rate limited to avoid excessive logging.

No new configuration property or per-probe log statement is added; HEALTH uses the existing disabled-routes setting.

Concurrency-Specific Checks

Both reviewer and PR author to verify

  • Code has no race conditions or thread safety issues.
  • Proper synchronization mechanisms (e.g., synchronized, RWLock) are used where needed.
  • No blocking calls inside critical sections that could lead to deadlocks or performance degradation.
  • Verified thread-safe collections are used (e.g., ConcurrentHashMap, CopyOnWriteArrayList).
  • Validated proper exception handling in multi-threaded code to avoid silent thread termination.

The startup transition uses compare-and-set so late startup cannot overwrite terminal shutdown. Each probe evaluates the required local services directly, then reads the lifecycle phase once. It introduces no collection, lifecycle lock or background thread. Restart creates a fresh controller owner.

How was this PR tested?

Testing Done

Six focused test methods cover the readiness signal, handler response, audit/metrics behavior, actual owner wiring and mock-listener lifecycle. The owner test calls real startup/shutdown with controlled services and covers child HTTP/HTTPS configurations, ACTIVE/PASSIVE parents, failed startup, required-service gates, registration/unregistration ordering and shutdown during a service-state check. The mock-listener test checks 200 OK after startup and 503 NOT_READY before listener teardown.

The existing loopback test runs with SSL enforcement enabled and disabled. It checks GET 200/503 responses with no INFO audit logs, retained metrics, disabled routes, and normal auditing and SSL enforcement for POST and slash-alias requests. All 20 selected controller and mock-server cases passed, including the existing four mock-server test methods; scoped Spotless checks passed after correcting one line-wrap violation.

The earlier 22 selected cases, owner-wiring coverage, integration-helper consumer compilation and scoped Spotless checks passed. Real TLS handshakes and deployment/fault exercises were not run.

  • New unit tests added.
  • New integration tests added.
  • Modified or extended existing tests.
  • Verified backward compatibility (if applicable).

Does this PR introduce any user-facing or breaking changes?

  • No. You can skip the rest of this section.
  • Yes. Clearly explain the behavior change and its impact.

The old 13-argument AdminSparkServer convenience constructor and 14-argument full signature are replaced by one 15-argument constructor with explicit serialization and readiness wiring. Direct consumers must update. The reusable mock-server factory keeps its existing signature and now reports ready after successful startup instead of remaining permanently unready. Other business API behavior is unchanged.

Expose a parameter-free GET /health route on the existing API listener.
Return a fixed liveness response without administrative lookups, and
reuse the disabled-routes setting while preserving other route security.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is focused, consistent with existing routing infrastructure, and comprehensively tested.

0 open findings

What changed in this PR

Adds a lightweight controller liveness endpoint independent of controller readiness and leadership.

Changes:

  • Adds parameter-free GET /health, returning plain-text OK.
  • Integrates health routing with SSL exceptions, disabled routes, and metrics.
  • Adds HTTP/HTTPS, TLS policy, route, and configuration tests.
File Description
AdminSparkServer.java Registers and permits the health endpoint.
AdminSparkServerTest.java Tests liveness and security behavior.
ControllerRoute.java Defines the health route.
ControllerRouteDimensionTest.java Verifies route metadata and dimensions.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

kvargha and others added 2 commits October 7, 2026 16:50
Keep health unready until controller initialization completes and the
required local API services can serve requests. Invalidate readiness
before shutdown and prevent late startup from restoring it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve upstream push-job serializer injection alongside the API
readiness signal in both controller listeners.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 00:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The endpoint implements lifecycle and regional readiness despite the PR specifying constant listener liveness.

1 open finding

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Use one shared three-state signal while preserving the original startup
sequence. Keep health unready until successful initialization and prevent
late completion from undoing shutdown.

Replace the broad test fixtures with focused state, response and policy
checks, retaining existing route, job and stats regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Owner-level lifecycle and eligibility wiring lacks the comprehensive tests claimed in the PR description.

2 open findings

🧠 Review effort: Balanced

Explain startup, shutdown and optional HTTPS requirements without changing readiness behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Frequent readiness probes currently generate two INFO audit logs per request, creating avoidable operational log volume.

2 open findings
Previously missed (1)

In code that hasn't changed since last review

Medium severity Readiness probes generate excessive audit INFO logs

services/​venice-controller/​src/​main/​java/​com/​linkedin/​venice/​controller/​server/​AdminSparkServer.java:412

Registering a readiness probe here also sends every GET /health through the global audit filters, which log both the request and completion at INFO (lines 336 and 378/381). Readiness agents poll continuously, so this creates two log records per probe on each listener and can materially increase controller log volume. Please exempt HEALTH from those audit INFO calls while retaining its metrics/failure marker, or rate-limit the probe logs.

🧠 Review effort: Balanced

Simplify readiness constructor wiring and suppress health audit INFO
logs while preserving request metrics and other API auditing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The modified public AdminSparkServer constructor breaks compatibility by removing its previous signature.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Non-GET health requests incorrectly bypass SSL enforcement and audit logging.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Match the HTTP method and raw path before skipping health audit logs or
SSL enforcement. Preserve normal handling of POST and slash-alias paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented readiness contract and includes focused coverage of lifecycle, concurrency, routing, metrics, and auditing behavior.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Restore the existing request and completion audit logging for health.
Keep the exact GET /health check only in the HTTP SSL exception.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Health probes still emit INFO audit logs, contrary to the documented lightweight endpoint contract.

1 open finding

🧠 Review effort: Balanced

Restore audit suppression for exact GET /health and document why periodic
probes should not generate repetitive INFO logs. Preserve all metrics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Health audit-log suppression contradicts the documented behavior and latest review resolution.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented readiness contract and includes focused lifecycle and endpoint coverage.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@kvargha
kvargha enabled auto-merge (squash) October 9, 2026 21:02
KaiSernLim
KaiSernLim previously approved these changes Oct 9, 2026
@kvargha
kvargha disabled auto-merge October 9, 2026 23:38
Distinguish regional ACTIVE/PASSIVE failover from host-level cluster
leadership without changing readiness behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 03:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented readiness contract and includes focused coverage of lifecycle, concurrency, routing, metrics, and SSL behavior.

0 open findings

🧠 Review effort: Balanced

Evaluate local service readiness directly, then read the lifecycle phase
once. Rename the terminal shutdown state to STOPPING and retain the
fail-closed startup transition.

Keep one live readiness callback for both API listeners and preserve
parent-region eligibility.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 03:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The readiness lifecycle, endpoint behavior, security exceptions, metrics, auditing, and configuration handling are consistently implemented and tested.

0 open findings

🧠 Review effort: Balanced

Remove the default-false AdminSparkServer convenience constructor.
Keep default serialization and lifecycle-backed mock readiness in the
existing ServiceFactory helper.

Preserve production owner callbacks and validate mock health before
listener teardown.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the documented readiness contract and provides focused lifecycle, routing, security-policy, logging, and metrics coverage.

0 open findings

🧠 Review effort: Balanced

@kvargha
kvargha enabled auto-merge (squash) October 10, 2026 04:51

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants