kumahq / kuma

🐻 The multi-zone service mesh for containers, Kubernetes and VMs. Built with Envoy. CNCF Sandbox Project.
https://kuma.io/install
Apache License 2.0
3.63k stars 331 forks source link

targetRef matching API improvements #8681

Open slonka opened 9 months ago

slonka commented 9 months ago

Description

It's not always clear how to call functions like MatchedPolicies and what to do with the results without digging into implementation. For single item rules sometimes we call .Compute on it like here https://github.com/kumahq/kuma/blob/4b04a600230b2598f516017a1d5e3abdabe10001/pkg/plugins/policies/meshproxypatch/plugin/v1alpha1/plugin.go#L41 (and why is MeshSubset hardcoded not taken from targetRef?) and sometimes we just get the Rules[0] https://github.com/kumahq/kuma/blob/60024abf3876297acb668f55773e883e21823961/pkg/plugins/policies/meshtrace/plugin/v1alpha1/plugin.go#L134-L135 - which one is correct? what about From/To rules?

The algorithm is nicely documented on the website https://kuma.io/docs/2.5.x/policies/targetref/#understanding-targetref-policies but I think we could do a better job explaining in code what's what and how to use it.

Tagging @lobkovilya because he probably knows best.

michaelbeaumont commented 9 months ago

Maybe we can structure the types such that you can't use both

jakubdyszkiewicz commented 9 months ago

xref https://github.com/kumahq/kuma/issues/8155

Triage: both ways are correct. We could unify those occurrences of the code. Also consider documenting .Compute function.

github-actions[bot] commented 6 months ago

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.

github-actions[bot] commented 3 months ago

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.

github-actions[bot] commented 1 day ago

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.