Skip to content

Exclude terminating pods from MCPServer ReadyReplicas count#4609

Open
olamide226 wants to merge 1 commit intostacklok:mainfrom
olamide226:fix/exclude-terminating-pods-from-ready-count
Open

Exclude terminating pods from MCPServer ReadyReplicas count#4609
olamide226 wants to merge 1 commit intostacklok:mainfrom
olamide226:fix/exclude-terminating-pods-from-ready-count

Conversation

@olamide226
Copy link
Copy Markdown
Contributor

@olamide226 olamide226 commented Apr 7, 2026

Summary

  • During rolling updates, pods with DeletionTimestamp set (terminating) were still counted as ready in MCPServer status, inflating ReadyReplicas beyond the desired replica count
  • Added a guard clause in categorizePodStatus() to return early for terminating pods, excluding them from running/pending/failed counts

Fixes #4498

Type of change

  • Bug fix

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)
  • Manual testing (against a cluster workload)

Changes

File Change
cmd/thv-operator/controllers/mcpserver_controller.go Skip pods with DeletionTimestamp != nil in categorizePodStatus()
cmd/thv-operator/controllers/mcpserver_replicas_test.go Add unit + integration tests for terminating pod exclusion

Does this introduce a user-facing change?

No — fixes incorrect status reporting during rolling updates. No API or CRD changes.

@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Apr 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.90%. Comparing base (4bb35be) to head (0e460c4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4609      +/-   ##
==========================================
+ Coverage   68.83%   68.90%   +0.07%     
==========================================
  Files         505      505              
  Lines       52437    52439       +2     
==========================================
+ Hits        36095    36135      +40     
+ Misses      13550    13510      -40     
- Partials     2792     2794       +2     

☔ 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.

@olamide226 olamide226 force-pushed the fix/exclude-terminating-pods-from-ready-count branch from 3f0980b to 1e57da6 Compare April 7, 2026 12:30
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Apr 7, 2026
@olamide226 olamide226 marked this pull request as ready for review April 7, 2026 17:34
Copilot AI review requested due to automatic review settings April 7, 2026 17:34
During rolling updates, pods with DeletionTimestamp set were still
counted as ready, inflating ReadyReplicas beyond the desired replica
count. Add a guard clause in categorizePodStatus() to skip pods that
are being terminated.

Fixes stacklok#4498
@olamide226 olamide226 force-pushed the fix/exclude-terminating-pods-from-ready-count branch from 1e57da6 to 0e460c4 Compare April 7, 2026 17:35
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Apr 7, 2026
Copy link
Copy Markdown
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 inflated MCPServer status ReadyReplicas during rolling updates by excluding terminating (DeletionTimestamp set) pods from readiness counting.

Changes:

  • Add an early return in categorizePodStatus() to skip terminating pods.
  • Add unit-style coverage for categorizePodStatus() and a status update test ensuring terminating-but-ready pods don’t inflate ReadyReplicas.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/thv-operator/controllers/mcpserver_controller.go Excludes terminating pods from running/pending/failed counts used to compute ReadyReplicas.
cmd/thv-operator/controllers/mcpserver_replicas_test.go Adds tests validating terminating pods are excluded from categorizePodStatus and updateMCPServerStatus.

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

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

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Inflated ReadyReplicas During Rolling Updates in k8s

2 participants