From dd575bd0a8e83409b64a779af93338be7900cfc9 Mon Sep 17 00:00:00 2001 From: Samuel Padgett Date: Mon, 30 Jan 2017 13:16:53 -0500 Subject: [PATCH] Show router canonical hostname on route page If the route has a custom hostname and the router has a canonical hostname configured, show a message on the route page about setting up the DNS CNAME record. --- app/scripts/controllers/route.js | 43 +++++++++++++++++++- app/scripts/services/routes.js | 6 ++- app/styles/_core.less | 5 +++ app/views/browse/route.html | 66 ++++++++++++++++++------------- dist/scripts/scripts.js | 67 +++++++++++++++++++------------- dist/scripts/templates.js | 42 +++++++++++++------- dist/styles/main.css | 1 + 7 files changed, 159 insertions(+), 71 deletions(-) diff --git a/app/scripts/controllers/route.js b/app/scripts/controllers/route.js index 5a99f121ec..9ab5d4df51 100644 --- a/app/scripts/controllers/route.js +++ b/app/scripts/controllers/route.js @@ -7,7 +7,14 @@ * Controller of the openshiftConsole */ angular.module('openshiftConsole') - .controller('RouteController', function ($scope, $routeParams, AlertMessageService, DataService, ProjectsService, $filter) { + .controller('RouteController', + function($scope, + $filter, + $routeParams, + AlertMessageService, + DataService, + ProjectsService, + RoutesService) { $scope.projectName = $routeParams.project; $scope.route = null; $scope.alerts = {}; @@ -31,9 +38,11 @@ angular.module('openshiftConsole') var watches = []; + var isCustomHost; var routeResolved = function(route, action) { $scope.loaded = true; $scope.route = route; + isCustomHost = RoutesService.isCustomHost(route); if (action === "DELETED") { $scope.alerts["deleted"] = { type: "warning", @@ -42,6 +51,38 @@ angular.module('openshiftConsole') } }; + // Use an alert key that has the route UID, route host, and router + // hostname. This will handle cases where the route is admitted by + // multiple routers and we have more than one alert. + var routerHostnameAlertKey = function(ingress) { + var uid = _.get($scope, 'route.metadata.uid'); + return 'router-host-' + uid + '-' + ingress.host + '-' + ingress.routerCanonicalHostname; + }; + + // Show the alert for admitted routes that have a custom host if + // routerCanonicalHostname is set. + $scope.showRouterHostnameAlert = function(ingress, admittedCondition) { + if (!isCustomHost) { + return false; + } + + if (!ingress || !ingress.host || !ingress.routerCanonicalHostname) { + return false; + } + + if (!admittedCondition || admittedCondition.status !== 'True') { + return false; + } + + var alertKey = routerHostnameAlertKey(ingress); + return !AlertMessageService.isAlertPermanentlyHidden(alertKey, $scope.projectName); + }; + + $scope.hideRouterHostnameAlert = function(ingress) { + var alertKey = routerHostnameAlertKey(ingress); + AlertMessageService.permanentlyHideAlert(alertKey, $scope.projectName); + }; + ProjectsService .get($routeParams.project) .then(_.spread(function(project, context) { diff --git a/app/scripts/services/routes.js b/app/scripts/services/routes.js index 07a57f8d55..1e84b47a08 100644 --- a/app/scripts/services/routes.js +++ b/app/scripts/services/routes.js @@ -92,8 +92,9 @@ angular.module("openshiftConsole") }); }; + var annotation = $filter('annotation'); var isCustomHost = function(route) { - return $filter('annotation')(route, "openshift.io/host.generated") !== "true"; + return annotation(route, "openshift.io/host.generated") !== "true"; }; // Gets a score for the route to decide which to show on the overview. @@ -164,6 +165,7 @@ angular.module("openshiftConsole") getServicePortForRoute: getServicePortForRoute, getPreferredDisplayRoute: getPreferredDisplayRoute, groupByService: groupByService, - getSubdomain: getSubdomain + getSubdomain: getSubdomain, + isCustomHost: isCustomHost }; }); diff --git a/app/styles/_core.less b/app/styles/_core.less index 86bd1d8999..f31c205c6f 100644 --- a/app/styles/_core.less +++ b/app/styles/_core.less @@ -200,6 +200,11 @@ mark { } } +.route-status .h3 { + margin-top: 0; + margin-bottom: 5px; +} + .deployment-config-summary { .gutter-bottom(); } diff --git a/app/views/browse/route.html b/app/views/browse/route.html index 1c10b2f179..2050cabf83 100644 --- a/app/views/browse/route.html +++ b/app/views/browse/route.html @@ -52,35 +52,49 @@

-
-
Hostnames:
-
- - {{route | routeLabel : null : true}} - - - Pending - +
+ + {{route | routeLabel : null : true}} + +
+ + The route is not accepting traffic yet because it has not been admitted by a router. +
+
+
+
+ + {{route | routeLabel : ingress.host : true}} -
- - {{route | routeLabel : ingress.host : true}} - - - {{route | routeLabel : ingress.host}} - - – - - admission status unknown for router '{{ingress.routerName}}' - - exposed on router '{{ingress.routerName}}' - - - rejected by router '{{ingress.routerName}}' - + + {{route | routeLabel : ingress.host}} + +
+
+ Admission status unknown for router '{{ingress.routerName}}' + + + Exposed on router '{{ingress.routerName}}' + + + + Rejected by router '{{ingress.routerName}}' + +
+
+
+ + + The DNS admin should set up a CNAME from the route's hostname, {{ingress.host}}, + to the router's canonical hostname, {{ingress.routerCanonicalHostname}}. + Don't Show Me Again
-
+
+
+ +

Details

+
Wildcard Policy:
{{route.spec.wildcardPolicy}}
Path:
diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js index 172adc0aa5..a3d4ab52ac 100644 --- a/dist/scripts/scripts.js +++ b/dist/scripts/scripts.js @@ -3360,19 +3360,19 @@ type:"Admitted", status:"True" }); }); -}, h = function(b) { -return "true" !== a("annotation")(b, "openshift.io/host.generated"); -}, i = function(a) { +}, h = a("annotation"), i = function(a) { +return "true" !== h(a, "openshift.io/host.generated"); +}, j = function(a) { var b = 0; g(a) && (b += 11); var c = _.get(a, "spec.alternateBackends"); -return _.isEmpty(c) || (b += 5), h(a) && (b += 3), a.spec.tls && (b += 1), b; -}, j = function(a, b) { -var c = i(a), d = i(b); +return _.isEmpty(c) || (b += 5), i(a) && (b += 3), a.spec.tls && (b += 1), b; +}, k = function(a, b) { +var c = j(a), d = j(b); return d > c ? b :a; -}, k = function(a) { -return _.groupBy(a, "spec.to.name"); }, l = function(a) { +return _.groupBy(a, "spec.to.name"); +}, m = function(a) { var b = _.get(a, "spec.host", ""); return b.replace(/^[a-z0-9]([-a-z0-9]*[a-z0-9])\./, ""); }; @@ -3382,9 +3382,10 @@ var c = []; return a ? ("Service" === a.spec.to.kind && d(a, b, c), e(a, c), f(a, c), c) :c; }, getServicePortForRoute:c, -getPreferredDisplayRoute:j, -groupByService:k, -getSubdomain:l +getPreferredDisplayRoute:k, +groupByService:l, +getSubdomain:m, +isCustomHost:i }; } ]), angular.module("openshiftConsole").factory("ChartsService", [ "Logger", function(a) { return { @@ -6888,34 +6889,46 @@ b.routes = a.select(b.unfilteredRoutes), e(); d.unwatchAll(h); }); })); -} ]), angular.module("openshiftConsole").controller("RouteController", [ "$scope", "$routeParams", "AlertMessageService", "DataService", "ProjectsService", "$filter", function(a, b, c, d, e, f) { -a.projectName = b.project, a.route = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ { +} ]), angular.module("openshiftConsole").controller("RouteController", [ "$scope", "$filter", "$routeParams", "AlertMessageService", "DataService", "ProjectsService", "RoutesService", function(a, b, c, d, e, f, g) { +a.projectName = c.project, a.route = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ { title:"Routes", -link:"project/" + b.project + "/browse/routes" +link:"project/" + c.project + "/browse/routes" }, { -title:b.route -} ], c.getAlerts().forEach(function(b) { +title:c.route +} ], d.getAlerts().forEach(function(b) { a.alerts[b.name] = b.data; -}), c.clearAlerts(); -var g = [], h = function(b, c) { -a.loaded = !0, a.route = b, "DELETED" === c && (a.alerts.deleted = { +}), d.clearAlerts(); +var h, i = [], j = function(b, c) { +a.loaded = !0, a.route = b, h = g.isCustomHost(b), "DELETED" === c && (a.alerts.deleted = { type:"warning", message:"This route has been deleted." }); -}; -e.get(b.project).then(_.spread(function(c, e) { -a.project = c, d.get("routes", b.route, e).then(function(a) { -h(a), g.push(d.watchObject("routes", b.route, e, h)); -}, function(b) { +}, k = function(b) { +var c = _.get(a, "route.metadata.uid"); +return "router-host-" + c + "-" + b.host + "-" + b.routerCanonicalHostname; +}; +a.showRouterHostnameAlert = function(b, c) { +if (!h) return !1; +if (!b || !b.host || !b.routerCanonicalHostname) return !1; +if (!c || "True" !== c.status) return !1; +var e = k(b); +return !d.isAlertPermanentlyHidden(e, a.projectName); +}, a.hideRouterHostnameAlert = function(b) { +var c = k(b); +d.permanentlyHideAlert(c, a.projectName); +}, f.get(c.project).then(_.spread(function(d, f) { +a.project = d, e.get("routes", c.route, f).then(function(a) { +j(a), i.push(e.watchObject("routes", c.route, f, j)); +}, function(c) { a.loaded = !0, a.alerts.load = { type:"error", message:"The route details could not be loaded.", -details:"Reason: " + f("getErrorDetails")(b) +details:"Reason: " + b("getErrorDetails")(c) }; -}), g.push(d.watch("services", e, function(b) { +}), i.push(e.watch("services", f, function(b) { a.services = b.by("metadata.name"); })), a.$on("$destroy", function() { -d.unwatchAll(g); +e.unwatchAll(i); }); })); } ]), angular.module("openshiftConsole").controller("StorageController", [ "$routeParams", "$scope", "AlertMessageService", "DataService", "ProjectsService", "$filter", "LabelFilter", "Logger", function(a, b, c, d, e, f, g, h) { diff --git a/dist/scripts/templates.js b/dist/scripts/templates.js index db27e1934d..28498eb7c7 100644 --- a/dist/scripts/templates.js +++ b/dist/scripts/templates.js @@ -3635,35 +3635,47 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "
\n" + "
\n" + - "
\n" + - "
Hostname 1\">s:
\n" + - "
\n" + - "\n" + + "
\n" + + "\n" + "{{route | routeLabel : null : true}}\n" + - "\n" + - "\n" + - "Pending\n" + - "\n" + "\n" + - "
\n" + + "
\n" + + "\n" + + "The route is not accepting traffic yet because it has not been admitted by a router.\n" + + "
\n" + + "
\n" + + "
\n" + + "
\n" + "\n" + "{{route | routeLabel : ingress.host : true}}\n" + "\n" + "\n" + "{{route | routeLabel : ingress.host}}\n" + "\n" + - "–\n" + - "\n" + - "admission status unknown for router '{{ingress.routerName}}'\n" + + "
\n" + + "
\n" + + "Admission status unknown for router '{{ingress.routerName}}'\n" + "\n" + - "exposed on router '{{ingress.routerName}}' \n" + + "\n" + + "Exposed on router '{{ingress.routerName}}' \n" + "\n" + "\n" + - "rejected by router '{{ingress.routerName}}' \n" + + "\n" + + "Rejected by router '{{ingress.routerName}}' \n" + "\n" + + "
\n" + + "
\n" + + "
\n" + + "\n" + + "\n" + + "The DNS admin should set up a CNAME from the route's hostname, {{ingress.host}}, to the router's canonical hostname, {{ingress.routerCanonicalHostname}}.\n" + "\n" + + "Don't Show Me Again\n" + "
\n" + - "
\n" + + "
\n" + + "
\n" + + "

Details

\n" + + "
\n" + "
Wildcard Policy:
\n" + "
{{route.spec.wildcardPolicy}}
\n" + "
Path:
\n" + diff --git a/dist/styles/main.css b/dist/styles/main.css index 66427d3d25..4dcdb872b7 100644 --- a/dist/styles/main.css +++ b/dist/styles/main.css @@ -3790,6 +3790,7 @@ mark{padding:0;background-color:rgba(252,248,160,.5)} .build-config-summary .h3,.deployment-config-summary .h3{margin-bottom:0} .build-config-summary .last-status,.deployment-config-summary .last-status{margin-right:5px} .build-config-summary .last-timestamp,.deployment-config-summary .last-timestamp{margin-left:25px} +.route-status .h3{margin-top:0;margin-bottom:5px} .deployment-config-summary{padding-bottom:20px} .deployment-config-summary.gutter-bottom-2x{padding-bottom:40px} .registry-image-pull{margin-bottom:20px}