Skip to content

Conversation

@ciarams87
Copy link
Contributor

…status (#4214)

When HPA is enabled, read the current Deployment.Spec.Replicas directly instead of HPA.Status.DesiredReplicas, which is eventually consistent and lags behind deployment changes. This prevents the controller from overwriting HPA's replica count with stale values, eliminating pod churn and connection drops.

Fixes race condition where HPA scales down → NGF reads stale HPA status → NGF overwrites deployment with old replica count → pods restart.

Cherry-pick of #4214

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Preserve HPA replicas on deployment

…status (#4214)

When HPA is enabled, read the current Deployment.Spec.Replicas directly
instead of HPA.Status.DesiredReplicas, which is eventually consistent and
lags behind deployment changes. This prevents the controller from
overwriting HPA's replica count with stale values, eliminating pod churn
and connection drops.

Fixes race condition where HPA scales down → NGF reads stale HPA status
→ NGF overwrites deployment with old replica count → pods restart.
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.10%. Comparing base (bd30d48) to head (98f3b33).
⚠️ Report is 1 commits behind head on release-2.2.

Additional details and impacted files
@@               Coverage Diff               @@
##           release-2.2    #4239      +/-   ##
===============================================
- Coverage        86.13%   86.10%   -0.03%     
===============================================
  Files              131      131              
  Lines            14248    14257       +9     
  Branches            74       74              
===============================================
+ Hits             12272    12276       +4     
- Misses            1774     1778       +4     
- Partials           202      203       +1     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sjberman
Copy link
Collaborator

sjberman commented Nov 7, 2025

Be sure for future cherry pick PRs that the branch uses the proper name (bug/, fix/`, etc) so that the PR gets the proper labels for the auto-generated release notes.

@sjberman sjberman added the bug Something isn't working label Nov 7, 2025
@ciarams87 ciarams87 merged commit b3fdc43 into release-2.2 Nov 10, 2025
62 checks passed
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in NGINX Gateway Fabric Nov 10, 2025
@ciarams87 ciarams87 deleted the cp/hpa-scaling branch November 10, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working release-notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants