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

kuma-cp: pick a single the most specific TrafficRoute for every outbound interface of a Dataplane #421

Conversation

yskopets
Copy link
Contributor

Summary

  • pick a single the most specific TrafficRoute for every outbound interface of a Dataplane
    • match by an exact value is more specific than match by *
      • e.g., service: backend wins over service: *
    • match by N+1 tags is more specific than match by N tags
      • e.g., service: backend, version: v1 wins over service: backend
    • if 2 selectors have the same number of tags, the one that has more exact values is more specific
      • e.g., service: backend, version: v1 wins over service: backend, version: *
    • to compare a combination of source and destination selectors we sum up their numbers of exact and wildcard matching tags
      • e.g.,
        • given TrafficRoute 1:
          sources:
          - match:
               service: web
               version: '*'
          destinations:
          - match:
               service: backend         
        • and TrafficRoute 2:
          sources:
          - match:
               service: web
               version: '*'
          destinations:
          - match:
               service: '*'         
        • TrafficRoute 1 is more specific since it has 3 tags but only 1 wildcard vs 3 tags and 2 wildcards in case of TrafficRoute 2
    • when resolving a tie we consider lexicographical order of Namespace and Name of involved TrafficRoutes
      • e.g., in case of tie,
        • TrafficRoute from the namespace demo wins over a rule from the namespace test
        • when in the same namespace, TrafficRoute named Alice wins over TrafficRoute named Bob

@yskopets yskopets requested a review from a team November 11, 2019 00:41
@yskopets yskopets force-pushed the feature/select-the-most-specific-traffic-route-per-outbound-interface branch from 4497fa7 to dfa44b6 Compare November 11, 2019 00:58
@yskopets yskopets added this to the 0.3.0 milestone Nov 11, 2019
@yskopets yskopets force-pushed the feature/select-the-most-specific-traffic-route-per-outbound-interface branch from dfa44b6 to e22dd9a Compare November 11, 2019 10:28
@yskopets yskopets changed the base branch from feature/migrate-to-the-latest-go-control-plane to master November 11, 2019 13:02
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

I like the tests, it helped me understand the code.

if ok {
for _, destination := range route.Spec.Conf {
service, ok := destination.Destination[mesh_proto.ServiceTag]
if ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if there is no service tag here? I guess this should be caught be validation, but can we then log it if it's wrong or even fail with panic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm against a panic: a single invalid Dataplane resource should not crash the entire Control Plane.
Logging creates too much noise. A metric might be a proper solution here.
Although, Dataplane resource is invalid in the first place. So, users must have already been alarmed even without this implementation-specific metric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm adding a TODO here to consider exposing a metric

// skip dataplanes with invalid configuration
continue
}
// TODO(yskopets): do we need to dedup?
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be safer to do it. Can you maybe add an issue so we don't forget about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

},
Spec: mesh_proto.TrafficRoute{
Sources: []*mesh_proto.Selector{{
Match: mesh_proto.MatchService(mesh_proto.MatchAllTag),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe mesh_proto.MatchAll()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added MatchAnyService()

@yskopets yskopets force-pushed the feature/select-the-most-specific-traffic-route-per-outbound-interface branch from bacbfd0 to 2d8c64b Compare November 12, 2019 10:04
@yskopets yskopets force-pushed the feature/select-the-most-specific-traffic-route-per-outbound-interface branch from 2d8c64b to d48f59b Compare November 12, 2019 10:19
@yskopets yskopets merged commit be14f7b into master Nov 12, 2019
@yskopets yskopets deleted the feature/select-the-most-specific-traffic-route-per-outbound-interface branch December 19, 2019 19:41
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.

None yet

3 participants