Skip to content

fix: preserve order of node reports in healthcheck #10835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Nov 22, 2023

Fixes: #10824

The current HealthyWithNodeDegraded test implementation assumes that the order of node reports is stable and sorted by node name. Unfortunately, that assumption was wrong, so this PR modifies the healthcheck logic to preserve the order.

@mtojek mtojek self-assigned this Nov 22, 2023
@mtojek mtojek marked this pull request as ready for review November 22, 2023 09:39
Comment on lines 504 to 505
sorted := make([]*NodeReport, len(reports))
copy(sorted, reports)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to make a copy? We're holding the mutex aren't we?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes, thanks

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

slices.SortFunc is not guaranteed to be stable, but I figure stability is up to the func you pass in, correct?

@mtojek
Copy link
Member Author

mtojek commented Nov 22, 2023

Correct. In our case, it should be stable as we don't have more than one report for nodes with the same name.

@mtojek mtojek merged commit 8dd003b into main Nov 22, 2023
@mtojek mtojek deleted the 10824-node-degraded-2 branch November 22, 2023 10:15
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake: TestDERP/HealthyWithNodeDegraded
2 participants