ui: Update to not return metrics for ingress gateways (#9081)

This commit is contained in:
Kenia 2020-11-02 13:38:43 -05:00 committed by GitHub
parent ae6185a554
commit 56c2ff56e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 27 deletions

View File

@ -45,18 +45,18 @@
</dl> </dl>
{{/if}} {{/if}}
</div> </div>
{{#if @hasMetricsProvider }} {{#if (and @hasMetricsProvider (not-eq @service.Kind 'ingress-gateway'))}}
{{#if (eq @type 'upstream')}} {{#if (eq @type 'upstream')}}
<TopologyMetrics::Stats <TopologyMetrics::Stats
@endpoint='upstream-summary-for-service' @endpoint='upstream-summary-for-service'
@service={{@service}} @service={{@service.Service}}
@item={{item.Name}} @item={{item.Name}}
@noMetricsReason={{@noMetricsReason}} @noMetricsReason={{@noMetricsReason}}
/> />
{{else}} {{else}}
<TopologyMetrics::Stats <TopologyMetrics::Stats
@endpoint='downstream-summary-for-service' @endpoint='downstream-summary-for-service'
@service={{@service}} @service={{@service.Service}}
@item={{item.Name}} @item={{item.Name}}
@noMetricsReason={{@noMetricsReason}} @noMetricsReason={{@noMetricsReason}}
/> />

View File

@ -13,7 +13,7 @@
</div> </div>
<TopologyMetrics::Card <TopologyMetrics::Card
@items={{@topology.Downstreams}} @items={{@topology.Downstreams}}
@service={{@service.Service.Service}} @service={{@service.Service}}
@dc={{@topology.Datacenter}} @dc={{@topology.Datacenter}}
@hasMetricsProvider={{this.hasMetricsProvider}} @hasMetricsProvider={{this.hasMetricsProvider}}
@noMetricsReason={{this.noMetricsReason}} @noMetricsReason={{this.noMetricsReason}}
@ -31,6 +31,7 @@
@protocol={{@topology.Protocol}} @protocol={{@topology.Protocol}}
@noMetricsReason={{this.noMetricsReason}} @noMetricsReason={{this.noMetricsReason}}
/> />
{{#if (not-eq @service.Service.Kind 'ingress-gateway')}}
<TopologyMetrics::Stats <TopologyMetrics::Stats
@endpoint='summary-for-service' @endpoint='summary-for-service'
@service={{@service.Service.Service}} @service={{@service.Service.Service}}
@ -39,6 +40,7 @@
@noMetricsReason={{this.noMetricsReason}} @noMetricsReason={{this.noMetricsReason}}
/> />
{{/if}} {{/if}}
{{/if}}
<div class="link"> <div class="link">
{{#if @metricsHref}} {{#if @metricsHref}}
<a class="metrics-link" href={{@metricsHref}} target="_blank" rel="noopener noreferrer" data-test-metrics-anchor>Open metrics Dashboard</a> <a class="metrics-link" href={{@metricsHref}} target="_blank" rel="noopener noreferrer" data-test-metrics-anchor>Open metrics Dashboard</a>
@ -63,7 +65,7 @@
<p>{{dc}}</p> <p>{{dc}}</p>
<TopologyMetrics::Card <TopologyMetrics::Card
@items={{upstreams}} @items={{upstreams}}
@service={{@service.Service.Service}} @service={{@service.Service}}
@dc={{@topology.Datacenter}} @dc={{@topology.Datacenter}}
@type='upstream' @type='upstream'
@hasMetricsProvider={{this.hasMetricsProvider}} @hasMetricsProvider={{this.hasMetricsProvider}}

View File

@ -26,7 +26,10 @@ export default class TopologyMetrics extends Component {
// TODO we can make the configurable even before we have a full solution for // TODO we can make the configurable even before we have a full solution for
// multi-DC forwarding for Prometheus so providers that are global for all // multi-DC forwarding for Prometheus so providers that are global for all
// DCs like an external managed APM can still load in all DCs. // DCs like an external managed APM can still load in all DCs.
if (this.env.var('CONSUL_DATACENTER_LOCAL') != this.args.topology.get('Datacenter')) { if (
this.env.var('CONSUL_DATACENTER_LOCAL') !== this.args.topology.get('Datacenter') ||
this.args.service.Service.Kind === 'ingress-gateway'
) {
this.noMetricsReason = 'Unable to fetch metrics for a remote datacenter'; this.noMetricsReason = 'Unable to fetch metrics for a remote datacenter';
} }
} }

View File

@ -11,12 +11,9 @@ export default Route.extend({
// so check the length here. // so check the length here.
let to = 'topology'; let to = 'topology';
const parentModel = this.modelFor(parent); const parentModel = this.modelFor(parent);
const hasProxy = get(parentModel, 'proxies'); const hasProxy = get(parentModel, 'proxies.length') !== 0;
const kind = get(parentModel, 'items.firstObject.Service.Kind'); const kind = get(parentModel, 'items.firstObject.Service.Kind');
if (hasProxy.length === 0) {
to = 'instances';
} else {
switch (kind) { switch (kind) {
case 'ingress-gateway': case 'ingress-gateway':
if (!get(parentModel, 'topology.Datacenter')) { if (!get(parentModel, 'topology.Datacenter')) {
@ -30,11 +27,10 @@ export default Route.extend({
to = 'instances'; to = 'instances';
break; break;
default: default:
if (!get(parentModel, 'topology.Datacenter')) { if (!hasProxy || !get(parentModel, 'topology.Datacenter')) {
to = 'instances'; to = 'instances';
} }
} }
}
this.replaceWith(`${parent}.${to}`, parentModel); this.replaceWith(`${parent}.${to}`, parentModel);
}, },

View File

@ -29,7 +29,7 @@
<TabNav @items={{ <TabNav @items={{
compact compact
(array (array
(if (and topology.Datacenter (gt proxies.length 0)) (if (and topology.Datacenter (or (gt proxies.length 0) (eq item.Service.Kind 'ingress-gateway')))
(hash label="Topology" href=(href-to "dc.services.show.topology") selected=(is-href "dc.services.show.topology")) (hash label="Topology" href=(href-to "dc.services.show.topology") selected=(is-href "dc.services.show.topology"))
'') '')
(if (eq item.Service.Kind 'terminating-gateway') (if (eq item.Service.Kind 'terminating-gateway')