From a9d9778da9dd34818d3944c428823c715eaa1bf4 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 10 Jun 2019 13:50:09 +0000 Subject: [PATCH] ui: Normal proxies line to services, sidecars to instances Folllowing on from https://github.com/hashicorp/consul/pull/5933 we noticed that 'normal' proxies should link to the service, rather than the service instance. Additionally sideproxy 'searching' within the repository should take into account the name of the node that the originating service is on (sidecar proxies are generally co-located) Added an additiojnal test here to prove that a sidecar-proxy with the same service id but on a different node does not show the sidecar proxy link. --- ui-v2/app/services/repository/proxy.js | 2 +- ui-v2/app/templates/dc/services/instance.hbs | 9 +++++-- .../services/instances/with-sidecar.feature | 25 ++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ui-v2/app/services/repository/proxy.js b/ui-v2/app/services/repository/proxy.js index 2e74b39b0d6e..4a3a68b1ed4e 100644 --- a/ui-v2/app/services/repository/proxy.js +++ b/ui-v2/app/services/repository/proxy.js @@ -23,7 +23,7 @@ export default RepositoryService.extend({ return this.findAllBySlug(slug, dc, configuration).then(function(items) { let res = {}; if (get(items, 'length') > 0) { - let instance = items.findBy('ServiceProxy.DestinationServiceID', id); + let instance = items.filterBy('ServiceProxy.DestinationServiceID', id).findBy('Node', node); if (instance) { res = instance; } else { diff --git a/ui-v2/app/templates/dc/services/instance.hbs b/ui-v2/app/templates/dc/services/instance.hbs index b5aae2b9eae6..10cbf3378782 100644 --- a/ui-v2/app/templates/dc/services/instance.hbs +++ b/ui-v2/app/templates/dc/services/instance.hbs @@ -33,8 +33,13 @@ {{#if proxy.ServiceName}}
-
{{if proxy.ServiceProxy.DestinationServiceID "Sidecar " ""}}Proxy
-
{{proxy.ServiceID}}
+{{#if proxy.ServiceProxy.DestinationServiceID}} +
Sidecar Proxy
+
{{proxy.ServiceID}}
+{{else}} +
Proxy
+
{{proxy.ServiceName}}
+{{/if}}
{{/if}} {{#if (eq item.Kind 'connect-proxy')}} diff --git a/ui-v2/tests/acceptance/dc/services/instances/with-sidecar.feature b/ui-v2/tests/acceptance/dc/services/instances/with-sidecar.feature index 7f1fa32a21ab..81d10cc13eec 100644 --- a/ui-v2/tests/acceptance/dc/services/instances/with-sidecar.feature +++ b/ui-v2/tests/acceptance/dc/services/instances/with-sidecar.feature @@ -4,8 +4,10 @@ Feature: dc / services / instances / with-sidecar: Show Service Instance with a Given 1 datacenter model with the value "dc1" And 1 proxy model from yaml --- - - ServiceProxy: - DestinationServiceID: service-1 + - Node: node-0 + ServiceProxy: + DestinationServiceID: service-0-with-id + DestinationServiceName: ~ --- When I visit the instance page for yaml --- @@ -16,8 +18,25 @@ Feature: dc / services / instances / with-sidecar: Show Service Instance with a --- Then the url should be /dc1/services/service-0/node-0/service-0-with-id And I see type on the proxy like "sidecar-proxy" - And I see serviceChecksIsSelected on the tabs And I don't see upstreams on the tabs + Scenario: A Service instance has no Sidecar Proxy (a DestinationServiceID) on the same node + Given 1 datacenter model with the value "dc1" + And 1 proxy model from yaml + --- + - Node: node-1 + ServiceProxy: + DestinationServiceID: service-0-with-id + DestinationServiceName: ~ + --- + When I visit the instance page for yaml + --- + dc: dc1 + service: service-0 + node: node-0 + id: service-0-with-id + --- + Then the url should be /dc1/services/service-0/node-0/service-0-with-id + Then I don't see type on the proxy