linkerd / linkerd2

Ultralight, security-first service mesh for Kubernetes. Main repo for Linkerd 2.x.
https://linkerd.io
Apache License 2.0
10.72k stars 1.28k forks source link

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

Closed DerekTBrown closed 1 week ago

DerekTBrown commented 2 weeks ago

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
olix0r commented 1 week ago

Do we need the same treatment for the conditions comparison?

https://github.com/linkerd/linkerd2/blob/826513463d7774d63fac5e72dcb3251f1b9bacc1/policy-controller/k8s/status/src/index.rs#L1538-L1553

DerekTBrown commented 1 week ago

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.