Skip to content

Conversation

@sjberman
Copy link
Collaborator

Problem: Due to a shared slice pointer, in certain scenarios we could get entries in the status list that don't belong there, and result in duplicate entries when writing the status to the route.

Solution: Copy the previous value before adding new entries, to avoid the shared slice.

Testing: Ran the benchmarking test and no longer saw the issue.

Closes #4249

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.

Fix an issue where duplicate status entries could be written on routes.

@sjberman sjberman requested a review from a team as a code owner November 11, 2025 00:09
@github-actions github-actions bot added the bug Something isn't working label Nov 11, 2025
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.13%. Comparing base (9d2bf35) to head (29033e6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4250      +/-   ##
==========================================
+ Coverage   86.11%   86.13%   +0.01%     
==========================================
  Files         131      131              
  Lines       14205    14217      +12     
  Branches       35       35              
==========================================
+ Hits        12233    12246      +13     
+ Misses       1768     1767       -1     
  Partials      204      204              

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

@tataruty
Copy link
Contributor

i would suggest to add some unit tests to check that deduplication works

@ciarams87 ciarams87 self-requested a review November 11, 2025 15:14
Copy link
Contributor

@ciarams87 ciarams87 left a comment

Choose a reason for hiding this comment

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

I didn't notice the failing unit test earlier - lgtm once that's fixed 😄

@sjberman
Copy link
Collaborator Author

@tataruty Good suggestion, I did explore doing that, but the issue I found is that this is not easily reproducible. I never could figure out how the slice gets accessed in multiple places at once (it baffles me because each time this function is called should be a new entry). When running the benchmark test, out of 1000 route creations, this issue may pop up only once.

Problem: Due to a shared slice pointer, in certain scenarios we could get entries in the status list that don't belong there, and result in duplicate entries when writing the status to the route.

Solution: Copy the previous value before adding new entries, to avoid the shared slice.
@sjberman sjberman merged commit aa0f45c into main Nov 11, 2025
61 of 62 checks passed
@sjberman sjberman deleted the bug/dupe-status branch November 11, 2025 22:44
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in NGINX Gateway Fabric Nov 11, 2025
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.

NGF adds duplicate status entries for other controllers

4 participants