Skip to content
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

[fix 13327] ignore HTTPRoute .status.parents re-ordering #13328

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

DerekTBrown
Copy link
Contributor

Commit Message:

[fix 13327] ignore HTTPRoute .status.parents re-ordering

The `eq_time_insensitive_route_parent_statuses` considers ordering when comparing statuses, even though ordering
doesn't matter. This can result in infite update loops.

Add logic to `eq_time_insensitive_route_parent_statuses` to pre-sort statuses before comparison, thus making the result independent of ordering.

A unit test was added to validate the fix.

Fixes #13327

@DerekTBrown DerekTBrown requested a review from a team as a code owner November 14, 2024 21:18
@DerekTBrown DerekTBrown changed the title [fixes 13327] ignore HTTPRoute .status.parents re-ordering [fix 13327] ignore HTTPRoute .status.parents re-ordering Nov 14, 2024
@olix0r
Copy link
Member

olix0r commented Nov 15, 2024

Do we need the same treatment for the conditions comparison?

fn eq_time_insensitive_conditions(
left: &[k8s_core_api::Condition],
right: &[k8s_core_api::Condition],
) -> bool {
if left.len() != right.len() {
return false;
}
left.iter().zip(right.iter()).all(|(l, r)| {
l.message == r.message
&& l.observed_generation == r.observed_generation
&& l.reason == r.reason
&& l.status == r.status
&& l.type_ == r.type_
})
}

@olix0r olix0r self-assigned this Nov 15, 2024
@DerekTBrown
Copy link
Contributor Author

Do we need the same treatment for the conditions comparison?

AFAIK, K8s preserves the order of lists in the HTTPRoute resource. The order of status.parents isn't guaranteed because multiple controllers could be modifying status.parents, and there isn't a contract between the controllers as to ordering. However, status.parents[(controllerName==linkerd.io/policy-controller)].conditions shouldn't be modified by outside controllers, so I don't think we strictly need to do order invariant comparison (since it should be in the order expected by linkerd).

All that said, it can't hurt (besides a little added complexity) to do order invariant comparison for conditions as well.

Up to you- happy to extend to cover conditions as well.

@olix0r olix0r enabled auto-merge (squash) November 15, 2024 19:41
Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

Thanks!

@olix0r olix0r merged commit f8a1343 into linkerd:main Nov 15, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants