Skip to content

Conversation

@spadgett
Copy link
Member

@spadgett spadgett commented Nov 9, 2016

Add web console support for creating wildcard routes. Show wildcard routes as *.my.subdomain on the overview and routes pages. Warn when the router has not admitted the wildcard policy.

openshift_web_console

screen shot 2016-11-09 at 3 11 06 pm

@jwforres @knobunc @rettori

@spadgett spadgett force-pushed the route-wildcards-b branch 2 times, most recently from cba203a to a53a570 Compare November 9, 2016 20:24
@spadgett
Copy link
Member Author

spadgett commented Nov 9, 2016

openshift_web_console


// true indicates that none of the routers support wildcard subdomains and
// removes the option from the route creation form.
DISABLE_WILDCARD_SUBDOMAINS: false,
Copy link
Member

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?

Copy link

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.

Copy link
Member Author

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 :)

Copy link

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.

Copy link
Member

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;
Copy link
Member

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

Copy link

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 :-(

// 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])./, '');
Copy link
Member

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 . ?

Copy link
Member Author

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,
Copy link
Member

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?

Copy link
Member Author

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

@knobunc
Copy link

knobunc commented Nov 10, 2016

@ramr It would be helpful if you took a look over the UI for this change. Thanks

@spadgett
Copy link
Member Author

Updated based on feedback from design review. /cc @rhamilto @ajacobs21e

openshift_web_console

If the user types *.example.com, we'll use www.example.com for host and set wildcardPolicy: 'Subdomain'.

@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.

@ramr
Copy link

ramr commented Nov 10, 2016

@spadgett if the router runs without wildcard support (ROUTER_ALLOW_WILDCARD_ROUTES=false or unset), then the route will get an error - the status would reflect that accordingly. This is what returns the error back:
https://github.com/openshift/origin/blob/master/pkg/cmd/infra/router/router.go#L140

@ramr
Copy link

ramr commented Nov 10, 2016

@spadgett @knobunc will review this in depth sometime later today.

@spadgett
Copy link
Member Author

@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

@ramr
Copy link

ramr commented Nov 10, 2016

@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);
Copy link

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.

Copy link
Member

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"

Copy link
Member

Choose a reason for hiding this comment

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

or maybe even "wildcard"

Copy link

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 + '.');
Copy link

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  

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, pulled the latest router image, and I see it now. It looks like we handle the case for both older and newer router images OK.

screen shot 2016-11-11 at 8 42 10 am

name: "theServiceName"
},
host: "www.example.com",
wildcardPolicy: "None",
Copy link

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.

Copy link
Member Author

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.']);
Copy link

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.

Copy link
Member Author

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 :)

@ajacobs21e
Copy link

@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?

@spadgett
Copy link
Member Author

did yesterday's technical discussion change the UI design?

@ajacobs21e No, my current working code is

#853 (comment)

which I think is what we agreed to during the design review?

Does changing the second sentence to "Generated if not specified" keep that whole section on one line?

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.

https://www.patternfly.org/styles/terminology-and-wording


// true indicates that none of the routers support wildcard subdomains and
// removes the option from the route creation form.
DISABLE_WILDCARD_SUBDOMAINS: false,
Copy link
Member

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

warnings.push(message);
}

if (wildcardPolicy === 'Subdomain' && ingress.wildcardPolicy !== wildcardPolicy) {
Copy link
Member

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.

@spadgett spadgett force-pushed the route-wildcards-b branch 4 times, most recently from af66bdf to f76fd34 Compare November 14, 2016 20:47
@spadgett spadgett changed the title [WIP] Add support for wildcard subdomains Add support for wildcard subdomains Nov 14, 2016
@spadgett
Copy link
Member Author

@jwforres thanks, updated

@jwforres
Copy link
Member

@spadgett looks like your spec test failed in travis https://travis-ci.org/openshift/origin-web-console/builds/175844167#L1782

@spadgett
Copy link
Member Author

looks like your spec test failed in travis

Oops, forgot to update the test for www -> wildcard prefix change

* 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
@spadgett
Copy link
Member Author

Fixed the test.

@jwforres jwforres added the lgtm Indicates that a PR is ready to be merged. label Nov 14, 2016
@ajacobs21e
Copy link

thanks @spadgett. I'm happy with the UI.

@jwforres
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 83ca258

@openshift-bot
Copy link

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link

Evaluated for origin web console test up to 83ca258

@openshift-bot
Copy link

Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/687/) (Base Commit: 3d8c136)

@openshift-bot
Copy link

openshift-bot commented Nov 17, 2016

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/708/) (Base Commit: 28c791a)

@openshift-bot openshift-bot merged commit 26e4d1f into openshift:master Nov 17, 2016
@spadgett spadgett deleted the route-wildcards-b branch November 17, 2016 17:59
spadgett added a commit to spadgett/openshift-docs that referenced this pull request Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants