Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Combine ingress paths and route rules #661

Merged
merged 11 commits into from
May 4, 2017

Conversation

kyessenov
Copy link
Contributor

The goal is to enable route rules on ingress rule destinations. I had to make concessions since it is not trivial to combine two Envoy HTTP routes. The ingress routes have the following restrictions:

  1. no weighted destination - can be added later by multiplying weights from ingress and destination rule and balancing them to 100.
  2. no header matching in ingress - it is not trivial to combine two sets of match conditions on headers, once they utilize regexes.
  3. no additional tags on destinations in ingress - we would need to apply the tags to destinations on destination rules, also non-trivial

These restrictions are not serious since we do not generate ingress rules that violate any of these from the ingress controller.

Additionally, I cleaned up some of the logic related to header matching: quoting prefix in a regex, detecting if a route is a catch-all, resolve service ports during route generation rather than rule generation.

Added a test to combine ingress with a route rule on "c".

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

Copy link
Member

@rshriram rshriram left a comment

Choose a reason for hiding this comment

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

overall looks good. Will leave it to others for Go nitpicks. Couple of concerns regarding the catch all route.

}
}

if useDefaultRoute {
Copy link
Member

Choose a reason for hiding this comment

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

I think we also need to add rules with a single route (same destination, 100 weight) as a catch all route.
examples of catch all routes:

  1. rule which has prefix /, no http headers and no path
  2. rule which has no match, with single route (weight 100)
  3. any thing else @frankbu ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic is same as it was before. I just moved catchAll to a function to simplify the control flow. Is there a specific example when the default rule is added or not added?

// CatchAll returns true if the route matches all requests
func (route *HTTPRoute) CatchAll() bool {
return len(route.Headers) == 0 && route.Path == "" && route.Prefix == "/"
}
Copy link
Member

Choose a reason for hiding this comment

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

if my http route rule does not provide path/prefix/headers, will route.Prefix still be set to / ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function assumes the route is valid (one of path or prefix is set). It looks like we set path and prefix in every route soon after instantiation. It's probably a good idea to move it to a factory method so that no invalid routes are created.

{
"name": "out.66fcc955b8875b19844f9eaf6cfda47c778c609e",
"weight": 25
}
Copy link
Member

Choose a reason for hiding this comment

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

nice work!

Copy link
Member

Choose a reason for hiding this comment

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

How do we match headers as well here?

Copy link
Contributor Author

@kyessenov kyessenov May 4, 2017

Choose a reason for hiding this comment

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

If there is a route rule on destination that uses headers, there should be two routes - one with header match, and another for catch-all. Both should be added, as long as they are compatible with ingress path/prefix.

Copy link
Contributor

@ijsnellf ijsnellf left a comment

Choose a reason for hiding this comment

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

Code LGTM

}
return dur
}

func protoDurationToMS(dur *duration.Duration) int64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest


if len(routes) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional): invert conditional check and continue to reduce nesting depth

func buildURIPathPrefix(matches *proxyconfig.MatchCondition) (path string, prefix string) {
path = ""
prefix = "/"
if matches != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

(optional): invert conditional check and continue to reduce nesting depth

@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest

@kyessenov
Copy link
Contributor Author

I'll follow up with a smaller PR to address some header/and code style things I noticed.

@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest

2 similar comments
@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest

@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest

@kyessenov
Copy link
Contributor Author

jenkins rebuild manager/e2e-smoketest

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job manager/e2e-smoketest passed

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

@kyessenov kyessenov merged commit dc17484 into istio:master May 4, 2017
@istio-testing
Copy link
Contributor

Jenkins job manager/e2e-smoketest passed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants