Skip to content

fix(vmcp): /status uses live health monitor state#4135

Open
yrobla wants to merge 1 commit intomainfrom
issue-4103
Open

fix(vmcp): /status uses live health monitor state#4135
yrobla wants to merge 1 commit intomainfrom
issue-4103

Conversation

@yrobla
Copy link
Contributor

@yrobla yrobla commented Mar 13, 2026

Summary

The /status endpoint was reading backend health from the static registry snapshot (set at discovery time and never updated), while /api/backends/health correctly read from the live health monitor. This caused the two endpoints to report inconsistent state for the same backend (issue #4103).

Fix buildStatusResponse() to call GetAllBackendHealthStates() and prefer the monitor's runtime health over the registry's initial value. When health monitoring is disabled the registry value is used as before, preserving backwards compatibility.

Add unit tests that assert /status reflects live monitor state for both healthy and unhealthy transitions, and an e2e It block in the circuit breaker lifecycle suite that compares both endpoints side-by-side once the unstable backend's circuit breaker opens.

Fixes #4103

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change

Does this introduce a user-facing change?

Special notes for reviewers

@yrobla yrobla requested a review from Copilot March 13, 2026 15:42
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes vMCP /status to report backend health using the live health monitor state (matching /api/backends/health) instead of the static registry snapshot, addressing inconsistent health reporting (Fixes #4103).

Changes:

  • Update buildStatusResponse() to prefer health monitor runtime state when available.
  • Add unit tests ensuring /status reflects healthy/unhealthy transitions from the monitor and falls back to the registry when monitoring is disabled.
  • Add E2E coverage comparing /status and /api/backends/health side-by-side in the circuit breaker lifecycle suite.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
pkg/vmcp/server/status.go Prefer live monitor health states when building /status output.
pkg/vmcp/server/status_test.go Add unit tests covering monitor-driven /status behavior and fallback behavior.
test/e2e/thv-operator/virtualmcp/helpers.go Add HTTP helpers + response structs for /status and /api/backends/health.
test/e2e/thv-operator/virtualmcp/virtualmcp_circuit_breaker_test.go Add E2E assertion that both endpoints agree on backend health.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e699150f8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.87%. Comparing base (b2cbbe1) to head (557a808).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4135      +/-   ##
==========================================
+ Coverage   68.13%   68.87%   +0.74%     
==========================================
  Files         461      461              
  Lines       46704    46571     -133     
==========================================
+ Hits        31821    32078     +257     
+ Misses      12105    11988     -117     
+ Partials     2778     2505     -273     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 13, 2026
The /status endpoint was reading backend health from the static
registry snapshot (set at discovery time and never updated), while
/api/backends/health correctly read from the live health monitor.
This caused the two endpoints to report inconsistent state for the
same backend (issue #4103).

Fix buildStatusResponse() to call GetAllBackendHealthStates() and
prefer the monitor's runtime health over the registry's initial
value. When health monitoring is disabled the registry value is
used as before, preserving backwards compatibility.

Add unit tests that assert /status reflects live monitor state for
both healthy and unhealthy transitions, and an e2e It block in the
circuit breaker lifecycle suite that compares both endpoints
side-by-side once the unstable backend's circuit breaker opens.

Closes: #4103
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vMCP /status reports backend as healthy while /api/backends/health reports unhealthy

3 participants