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

TrafficPermissions can shadow one another if the match the same destination #2417

Closed
lahabana opened this issue Jul 22, 2021 · 12 comments
Closed
Labels
area/api area/policies triage/accepted The issue was reviewed and is complete enough to start working on it

Comments

@lahabana
Copy link
Contributor

@cpu601 pointed out that:

  • with 3 service a, b and c.
  • an existing policy:
apiVersion: kuma.io/v1alpha1
kind: TrafficPermission
mesh: default
metadata:
  name: allow-b-to-a
spec:
  sources:
    - match:
        kuma.io/service: b
  destinations:
    - match:
        kuma.io/service: a
  • add a policy:
apiVersion: kuma.io/v1alpha1
kind: TrafficPermission
mesh: default
metadata:
  name: allow-c-to-a
spec:
  sources:
    - match:
        kuma.io/service: c
  destinations:
    - match:
        kuma.io/service: a

The second will take over the first one resulting in service b not able to communicate with service a anymore.

This has 2 issues:

  1. There's a massive risk of users shooting themselves in the foot (create a new policy that breaks existing connections when they seem unrelated)
  2. Shouldn't it be possible to have multiple policies for the same service?

If the answer to 2 is no and we decide that only 1 destination matcher set (.i.e: the map at spec.destinations.match) should be possible we should introduce validation at creation/modification time to not process this policy at all and avoid the shadowing explained here.

@jpeach
Copy link
Contributor

jpeach commented Jul 22, 2021

An inbound gets exactly 1 best-match TrafficPermission policy applied to it. So you can't apply both of these policies to same destination service at once (since it's inbound can only have 1 policy).

@lahabana
Copy link
Contributor Author

Right, just to reword my question and the idea behind this ticket:

  1. Is really a limitation we want to keep?
  2. If yes shouldn't the oldest permission have priority (rather than the newest like it is now) in order to avoid shooting yourself in the foot?
  3. Could we add validation to reject policies that already have the same exact destination matcher?

I'm not opposed to the single destination restriction, it just seems we might be able to improve the UX

@lobkovilya
Copy link
Contributor

Will this work?

apiVersion: kuma.io/v1alpha1
kind: TrafficPermission
mesh: default
metadata:
  name: allow-b-c-to-a
spec:
  sources:
    - match:
        kuma.io/service: b
    - match:
        kuma.io/service: c
  destinations:
    - match:
        kuma.io/service: a

Anyway, I think validation is a good idea. We have to provide more visibility of what policies were applied between Service A and Service B. Ideally it should be kumactl inspect --src=service-a --dst=service-b --policy=TrafficPermissionor something like this, but that's for the future

@lahabana
Copy link
Contributor Author

This does work but the user that hit did point out that:

a) Creation of a new permission broke something existing
b) It looked like it worked but it didn't which can be confusing from the user

I think @bdecoste was especially worried about users breaking everything by accident.

@jpeach
Copy link
Contributor

jpeach commented Aug 2, 2021

This does work but the user that hit did point out that:

a) Creation of a new permission broke something existing
b) It looked like it worked but it didn't which can be confusing from the user

Policies just float around in the API until they match something, and they can be pre-empted at anytime. Within that model it's hard for users to predict what will happen, so maybe we can give better tooling. For example

  • Given a YAML policy, show what objects it will affect before I create it
  • Posting a YAML resource (in a disabled state), then show what it matches before enabling

@lahabana
Copy link
Contributor Author

#3330 will fix this

@github-actions
Copy link
Contributor

This issue was inactive for 30 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 promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jan 14, 2022
@lahabana lahabana added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/stale Inactive for some time. It will be triaged again labels Jan 14, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 14, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 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 promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Apr 26, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label May 27, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 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 promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label May 27, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jun 27, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 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 promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jun 27, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 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 promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jul 29, 2022
@lobkovilya lobkovilya removed the triage/stale Inactive for some time. It will be triaged again label Jul 29, 2022
@lahabana
Copy link
Contributor Author

lahabana commented Oct 3, 2022

New policy matching as explained in: https://github.com/kumahq/kuma/blob/master/docs/madr/decisions/005-policy-matching.md solves this problem.

@lahabana lahabana closed this as completed Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api area/policies triage/accepted The issue was reviewed and is complete enough to start working on it
Projects
None yet
Development

No branches or pull requests

3 participants