-
Notifications
You must be signed in to change notification settings - Fork 4.7k
path based acls for routing #1235
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
Conversation
Path based ACLs are going to be quite slow. I had an explicit conversation with Willy on this topic and as always a new feature was delivered 'just for you'.
The file would contain all the host+path sorted from the longest to the shortest (basically just a sort -r) :
I had checked that with the commit from the git tree pre 1.5 release. You may want to verify the behaviour post-release. I tested with 150k backends and it was O(logn) and not O(n) anymore. |
@rajatchopra awesome, I'll look at changing the implementation to use map_beg. Thanks for the info. |
@rajatchopra PTAL - that cleans up the template significantly. |
@pweil- Looks good. Should we prefer putting the hostname lookup before the path based lookup? Just so that bulk goes through one step and minority through two. Assuming path based stuff is going to be in minority. |
@rajatchopra if you have both a path based and host based route for the same host you will never hit your path based route if the host based lookup is first. |
Yes. I meant never to put the path based hostnames in the host map. I think the logic just moves on if appropriate backend is not found. You may want to double-check this, though. I may be wrong. |
We may have crossed streams. Let me illustrate what I'm thinking. Let's say we have haproxy config of
user A has route1: www.example.com and route2: www.example.com/test. Which results in config files of:
if mapping for host comes first then a request to http://www.example.com/test will match the os_http_be.map lookup. Also, what I found was that if I used if TRUE it seemed to always end up at the default backend. I'm not discounting user error though, I can keep playing with it to see. But anyway, that's why I think the path based lookup needs to be first. Please correct me if that's faulty logic. |
548638f
to
2c0639a
Compare
@rajatchopra - based on our IRC conversation I've cleaned up this implementation. I realized that we can use a single file for all of this too. So now the lookup tries a path based check and if that fails it reverts to a host header check. I tested out what you were thinking about moving to the next use backend statement if lookup fails. That seems to work fine so long as the map result returns null. If anything is returned that doesn't exist it will fail which I think is fine because it indicates we have a map entry and no corresponding backend. Please take a look. |
[test] |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_openshift3/1299/) |
@rajatchopra @smarterclayton @ramr removing the WIP tag. Ready for review. Open item: is it ok for me to force a / at the beginning of the path field in validation or should I do a check + append? |
Be strict up front so users get what the expect:
|
updated with validations |
In what cases do you feel 'base' will not match but 'hdr(host)' will? Its a minor nit, though. Looks good to me otherwise. |
I meant there will be more apps without a path spec than with any. |
@rajatchopra this is particularly for use cases where someone has either both path based routes AND host based routes or only host based routes and making sure we match most specific to least: Only Host:
Host and Path:
|
Zomg make sure we have a test case for this :)
|
I'll add a new test method to the int test that tests this combination together. The individual isolated cases are covered. |
@@ -240,6 +273,146 @@ func TestRouter(t *testing.T) { | |||
} | |||
} | |||
|
|||
// TestRouterPathSpecificity tests that the router is matching routes from most specific to least when using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton @rajatchopra - this is a test for the use case I was mentioning. PTAL
Please leave final review on this. |
LGTM. Good work. |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_openshift3/1175/) (Image: devenv-fedora_1038) |
Evaluated for origin up to a7b4855 |
Merged by openshift-bot
…service-catalog/' changes from ae6b643caf..50e234de83 50e234de83 origin build: add origin tooling 092d7f8 Fix typos and resource names in walkthrough e2e logs (openshift#1237) d25bd11 Archive the old agenda doc, link to new one (openshift#1243) 6192d14 fix lint errors (openshift#1242) d103dad Fix lint errors and regenerate openapi (openshift#1238) e9328d3 Broker Relist (openshift#1183) b0f3222 Correct the reasons and messages set on the ready condition during async polling (openshift#1235) d2bb82f Re-enable the href checker (openshift#1232) 2c29654 Use feature gates in controller-manager (openshift#1231) 699eab9 switch build to go1.9 (openshift#1155) 7529ed8 broker resource secret authorization checking (openshift#1186) 50d9bdf v0.0.20 chart updates (openshift#1228) REVERT: ae6b643caf Use oc adm instead of oadm which might not exist in various installations. REVERT: 66a4eb2a2c Update instructions... will remove once documented elsewhere REVERT: 1b704d1530 replace build context setup with init containers REVERT: ee4df18c7f hack/lib: dedup os::util::host_platform and os::build::host_platform REVERT: 1cd6dfa998 origin: Switch out owners to Red Hatters REVERT: 664f4d318f Add instructions for syncing repos REVERT: 2f2cdd546b origin-build: delete files with colon in them REVERT: cdf8b12848 origin-build: don't build user-broker REVERT: ebfede9056 origin build: add _output to .gitignore REVERT: 55412c7e3d origin build: make build-go and build-cross work REVERT: 68c74ff4ae origin build: modify hard coded path REVERT: 3d41a217f6 origin build: add origin tooling git-subtree-dir: cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog git-subtree-split: 50e234de836b5e7c9e3d7d763847b99a0f0ea500
…service-catalog/' changes from ae6b643caf..06b897d198 06b897d198 origin build: add origin tooling 092d7f8 Fix typos and resource names in walkthrough e2e logs (openshift#1237) d25bd11 Archive the old agenda doc, link to new one (openshift#1243) 6192d14 fix lint errors (openshift#1242) d103dad Fix lint errors and regenerate openapi (openshift#1238) e9328d3 Broker Relist (openshift#1183) b0f3222 Correct the reasons and messages set on the ready condition during async polling (openshift#1235) d2bb82f Re-enable the href checker (openshift#1232) 2c29654 Use feature gates in controller-manager (openshift#1231) 699eab9 switch build to go1.9 (openshift#1155) 7529ed8 broker resource secret authorization checking (openshift#1186) 50d9bdf v0.0.20 chart updates (openshift#1228) REVERT: ae6b643caf Use oc adm instead of oadm which might not exist in various installations. REVERT: 66a4eb2a2c Update instructions... will remove once documented elsewhere REVERT: 1b704d1530 replace build context setup with init containers REVERT: ee4df18c7f hack/lib: dedup os::util::host_platform and os::build::host_platform REVERT: 1cd6dfa998 origin: Switch out owners to Red Hatters REVERT: 664f4d318f Add instructions for syncing repos REVERT: 2f2cdd546b origin-build: delete files with colon in them REVERT: cdf8b12848 origin-build: don't build user-broker REVERT: ebfede9056 origin build: add _output to .gitignore REVERT: 55412c7e3d origin build: make build-go and build-cross work REVERT: 68c74ff4ae origin build: modify hard coded path REVERT: 3d41a217f6 origin build: add origin tooling git-subtree-dir: cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog git-subtree-split: 06b897d1988a5a3c035c5a971c15b97cbc732918
[3.9] Bug 1567532 - Unidle handling in router should ignore headless services.
@rajatchopra @pmorie @ramr @akram @smarterclayton
All, this is the initial implementation of path based routing in the HAProxy router. Right now the router assumes that you're putting a / at the beginning of the route so a path based routing rule would look like the example below. I'd like some feedback on that assumption, if it is fine I'll add a validation rule to ensure the slash, if not then we can add the slash for users if preferrable.
Some notes for reviewers:
TODO: