-
Notifications
You must be signed in to change notification settings - Fork 229
Add support for wildcard subdomains #853
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
cba203a to
a53a570
Compare
app/scripts/constants.js
Outdated
|
|
||
| // true indicates that none of the routers support wildcard subdomains and | ||
| // removes the option from the route creation form. | ||
| DISABLE_WILDCARD_SUBDOMAINS: false, |
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.
@knobunc is it better to assume most routers will support this feature by default, or to assume most will not have it?
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.
We default it to false, but I don't know what admins will eventually do. I vote that we keep it false for now.
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.
I vote that we keep it false for now.
Note that the setting disables web console support for wildcards. So leaving it false will enable the feature. Just confirming that's what you mean :)
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.
;^) - btw, called ROUTER_ALLOW_WILDCARD_ROUTES (defaults to false) on the router side to keep you on your toes ... double negatives.
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.
@spadgett still need to switch the defaulting behavior here to match the router, I would probably do ALLOW_WILDCARD_ROUTES=false to match the setting in the router, but i would also be ok with DISABLE_WILDCARD_ROUTES=true for consistency with the other flags in the console. We will need to make sure in the docs that wherever the docs are for configuring the feature in the router that it also says how to configure the feature in the console. @ramr @knobunc do you know if the ansible installer is going to set the router flag?
also make sure this flag is only controlling the creation of these routes. No matter what if we see a wildcard route we should display it correctly
| route.spec.host = input.routing.host; | ||
| var host = input.routing.host; | ||
| if (route.spec.wildcardPolicy === 'Subdomain') { | ||
| host = 'www.' + input.routing.subdomain; |
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.
@knobunc are you ok with 'www' as the default we inject here under the covers
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.
I think you need to let them set it, but then let them set the wildcard flag separately.
I realized that we will expose those names when a router doesn't support wildcards, so we really do have to expose the full names to the end user :-(
app/scripts/services/routes.js
Outdated
| // For host "foo.example.com" return "example.com" | ||
| var getSubdomain = function(route) { | ||
| var hostname = _.get(route, 'spec.host', ''); | ||
| return hostname.replace(/^[a-z0-9]([-a-z0-9]*[a-z0-9])./, ''); |
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.
shouldn't that be a \. and not just a . ?
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.
Yes! thanks
| right: -3px; | ||
| } | ||
|
|
||
| .create-route-icon, |
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.
guessing these werent being used anywhere?
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.
guessing these werent being used anywhere?
Right
a53a570 to
abd2ed6
Compare
|
@ramr It would be helpful if you took a look over the UI for this change. Thanks |
|
Updated based on feedback from design review. /cc @rhamilto @ajacobs21e If the user types @knobunc I understand this isn't ideal if the router doesn't support wildcards. We were wondering if the entire route shouldn't be rejected if the wildcard policy can't be honored. It seems odd that the route is still admitted without the wildcards. |
b22e2bf to
8c9c697
Compare
|
@spadgett if the router runs without wildcard support ( |
|
@ramr This is the YAML I'm seeing. The route is admitted, but wildcard policy doesn't match? apiVersion: v1
kind: Route
metadata:
name: myroute
namespace: demo
selfLink: /oapi/v1/namespaces/demo/routes/myroute
uid: e76ac1c9-a778-11e6-b359-080027242396
resourceVersion: '47863'
creationTimestamp: '2016-11-10T19:07:20Z'
labels:
app: node-ex
spec:
host: www.mydomain.com
to:
kind: Service
name: node-ex
weight: 100
port:
targetPort: 8080-tcp
wildcardPolicy: Subdomain
status:
ingress:
- host: www.mydomain.com
routerName: router
conditions:
- type: Admitted
status: 'True'
lastTransitionTime: '2016-11-10T19:07:20Z'
wildcardPolicy: None |
8c9c697 to
5401bad
Compare
|
@spadgett looks like you have an older router image. The old router would admit the route in (since it doesn't understand wildcards). There was a discussion on this on: openshift/origin#11201 Anyway, the crux of that discussion is older routers would still admit in the route since they don't understand wildcards. That also allows routes to be backward compatible. For newer routers, since the feature is opt-in if you create a wildcard route and if the policy is not supported - it would reject it. Updated tried updating the link - how do you add a link containing hash/pound signs in markdown? |
| if (host) { | ||
| if (host.startsWith('*.')) { | ||
| route.spec.wildcardPolicy = 'Subdomain'; | ||
| route.spec.host = 'www' + host.substring(1); |
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.
Just a thought, might be better to use some name other than `www``. We do allow for multiple routes (wildcard + non)to coexist in a single namespace ... and www is more than likely to be a name used there for non-wildcard hosts.
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.
@ramr are you thinking something more like "generated" or "placeholder"
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.
or maybe even "wildcard"
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.
I like wildcard!
| } | ||
|
|
||
| if (wildcardPolicy === 'Subdomain' && ingress.wildcardPolicy !== wildcardPolicy) { | ||
| warnings.push('Router "' + ingress.routerName + '" does not support wildcard subdomains. Your route will only be available at host ' + ingress.host + '.'); |
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.
This will work for older routers (pre 1.4.0) which doesn't support wildcard subdomains.
On newer/the latest router (1.4.0) with wildcards disabled (ROUTER_ALLOW_WILDCARD_ROUTES=false or not set), status will be something like:
status:
ingress:
- conditions:
- lastTransitionTime: 2016-11-11T00:51:05Z
message: wildcard routes are not allowed
reason: RouteNotAdmitted
status: "False"
type: Admitted
host: wild.open.header.test
routerName: router
wildcardPolicy: Subdomain
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.
| name: "theServiceName" | ||
| }, | ||
| host: "www.example.com", | ||
| wildcardPolicy: "None", |
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.
Might want to also add a test case for wildcardPolicy: "" - though am not sure if the UI would ever see that.
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.
This is an object the web console is generating, so the value will always be set.
| wildcardPolicy: 'None' | ||
| }]; | ||
| var warnings = RoutesService.getRouteWarnings(route, serviceTemplate); | ||
| expect(warnings).toEqual(['Router "foo" does not support wildcard subdomains. Your route will only be available at host www.example.com.']); |
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.
The error message may be a bit different so you may want to check w/ older/newer router images.
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.
This particular error message is from the web console :)
|
@spadgett did yesterday's technical discussion change the UI design? Does changing the second sentence to "Generated if not specified" keep that whole section on one line? |
@ajacobs21e No, my current working code is which I think is what we agreed to during the design review?
Depends entirely on screen width. At the widest widths, it doesn't wrap the text even without those changes. At narrower widths, it will wrap the the updated text. We generally use complete sentences in the help text, which is how I interpret the Patternfly guidelines. |
app/scripts/constants.js
Outdated
|
|
||
| // true indicates that none of the routers support wildcard subdomains and | ||
| // removes the option from the route creation form. | ||
| DISABLE_WILDCARD_SUBDOMAINS: false, |
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.
@spadgett still need to switch the defaulting behavior here to match the router, I would probably do ALLOW_WILDCARD_ROUTES=false to match the setting in the router, but i would also be ok with DISABLE_WILDCARD_ROUTES=true for consistency with the other flags in the console. We will need to make sure in the docs that wherever the docs are for configuring the feature in the router that it also says how to configure the feature in the console. @ramr @knobunc do you know if the ansible installer is going to set the router flag?
also make sure this flag is only controlling the creation of these routes. No matter what if we see a wildcard route we should display it correctly
app/scripts/services/routes.js
Outdated
| warnings.push(message); | ||
| } | ||
|
|
||
| if (wildcardPolicy === 'Subdomain' && ingress.wildcardPolicy !== wildcardPolicy) { |
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.
Add a comment here that this will only show up for older routers that don't reject the route based on wildcard policy.
af66bdf to
f76fd34
Compare
f76fd34 to
81bd340
Compare
|
@jwforres thanks, updated |
|
@spadgett looks like your spec test failed in travis https://travis-ci.org/openshift/origin-web-console/builds/175844167#L1782 |
Oops, forgot to update the test for |
81bd340 to
83ca258
Compare
* Allow users to type "*.example.com" for route hostnames to create a wildcard route * Show wildcard routes as "*.example.com" on the overview and elsewhere
|
Fixed the test. |
|
thanks @spadgett. I'm happy with the UI. |
|
[merge] |
|
Evaluated for origin web console merge up to 83ca258 |
|
[Test]ing while waiting on the merge queue |
|
Evaluated for origin web console test up to 83ca258 |
|
Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/687/) (Base Commit: 3d8c136) |
|
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/708/) (Base Commit: 28c791a) |



Add web console support for creating wildcard routes. Show wildcard routes as
*.my.subdomainon the overview and routes pages. Warn when the router has not admitted the wildcard policy.@jwforres @knobunc @rettori