Skip to content

Commit f944a06

Browse files
authored
ui: [BACKPORT TO 1.9.x] Hide all metrics for ingress gateway services (#10934)
1 parent 761eefd commit f944a06

File tree

7 files changed

+47
-20
lines changed

7 files changed

+47
-20
lines changed

.changelog/10858.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
ui: Hide all metrics for ingress gateway services
3+
```

ui/packages/consul-ui/app/components/topology-metrics/index.hbs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
@hasMetricsProvider={{@hasMetricsProvider}}
2525
@noMetricsReason={{this.noMetricsReason}}
2626
>
27-
{{#if (and @hasMetricsProvider (not-eq @service.Service.Kind 'ingress-gateway'))}}
27+
{{#if (and @hasMetricsProvider this.mainNotIngressService (not-eq item.Kind 'ingress-gateway'))}}
28+
{{!-- One of the only places in the app where it's acceptable to default to 'default' namespace --}}
2829
<TopologyMetrics::Stats
30+
data-test-topology-metrics-downstream-stats
2931
@nspace={{or item.Namespace 'default'}}
3032
@dc={{item.Datacenter}}
3133
@endpoint='downstream-summary-for-service'
@@ -42,15 +44,15 @@
4244
<div class="metrics-header">
4345
{{@service.Service.Service}}
4446
</div>
45-
{{#if @hasMetricsProvider }}
47+
{{#if @hasMetricsProvider}}
4648
<TopologyMetrics::Series
4749
@nspace={{or @service.Service.Namespace 'default'}}
4850
@dc={{@dc}}
4951
@service={{@service.Service.Service}}
5052
@protocol={{@topology.Protocol}}
5153
@noMetricsReason={{this.noMetricsReason}}
5254
/>
53-
{{#if (not-eq @service.Service.Kind 'ingress-gateway')}}
55+
{{#if this.mainNotIngressService}}
5456
<TopologyMetrics::Stats
5557
@nspace={{or @service.Service.Namespace 'default'}}
5658
@dc={{@dc}}
@@ -91,7 +93,8 @@
9193
@item={{item}}
9294
@service={{@service.Service}}
9395
>
94-
{{#if (and @hasMetricsProvider (not-eq @service.Service.Kind 'ingress-gateway'))}}
96+
{{#if (and @hasMetricsProvider this.mainNotIngressService (not-eq item.Kind 'ingress-gateway'))}}
97+
{{!-- One of the only places in the app where it's acceptable to default to 'default' namespace --}}
9598
<TopologyMetrics::Stats
9699
@nspace={{or item.Namespace 'default'}}
97100
@dc={{item.Datacenter}}

ui/packages/consul-ui/app/components/topology-metrics/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from '@glimmer/component';
22
import { tracked } from '@glimmer/tracking';
3-
import { action } from '@ember/object';
3+
import { action, get } from '@ember/object';
44

55
export default class TopologyMetrics extends Component {
66
// =attributes
@@ -66,13 +66,19 @@ export default class TopologyMetrics extends Component {
6666
});
6767
}
6868

69+
get mainNotIngressService() {
70+
const kind = get(this.args.service.Service, 'Kind') || '';
71+
72+
return kind !== 'ingress-gateway';
73+
}
74+
6975
// =actions
7076
@action
7177
calculate() {
7278
if (this.args.isRemoteDC) {
73-
this.noMetricsReason = 'Unable to fetch metrics for a remote datacenter';
79+
this.noMetricsReason = 'remote-dc';
7480
} else if (this.args.service.Service.Kind === 'ingress-gateway') {
75-
this.noMetricsReason = 'Unable to fetch metrics for a ingress gateway';
81+
this.noMetricsReason = 'ingress-gateway';
7682
} else {
7783
this.noMetricsReason = null;
7884
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
{{#if @noMetricsReason}}
2-
<span class="topology-metrics-error">
3-
Unable to load metrics
4-
<span>
5-
<Tooltip>{{@noMetricsReason}}</Tooltip>
6-
</span>
1+
{{#if (or @noMetricsReason @error)}}
2+
<span data-test-topology-metrics-status class="topology-metrics-status-error">
3+
{{#if (eq @noMetricsReason 'ingress-gateway')}}
4+
{{t "components.topology-metrics.status.ingress-gateway"}}
5+
{{else if (eq @noMetricsReason 'remote-dc')}}
6+
{{t "components.topology-metrics.status.error"}}
7+
<span
8+
{{tooltip (t "components.topology-metrics.status.remote-dc")}}
9+
/>
10+
{{else if @error}}
11+
{{t "components.topology-metrics.status.error"}}
12+
{{/if}}
713
</span>
8-
{{else if @error}}
9-
<span class="topology-metrics-error">Unable to load metrics</span>
1014
{{else}}
11-
<span class="topology-metrics-loader">Loading Metrics</span>
15+
<span class="topology-metrics-status-loader">{{t "components.topology-metrics.status.loading"}}</span>
1216
{{/if}}

ui/packages/consul-ui/app/components/topology-metrics/status/index.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.topology-metrics-error,
2-
.topology-metrics-loader {
1+
.topology-metrics-status-error,
2+
.topology-metrics-status-loader {
33
font-weight: normal;
44
font-size: 0.875rem;
55
color: $gray-500;
@@ -13,6 +13,6 @@
1313
}
1414
}
1515

16-
span.topology-metrics-loader::after {
16+
span.topology-metrics-status-loader::after {
1717
@extend %with-loading-icon, %as-pseudo;
1818
}

ui/packages/consul-ui/mock-api/v1/internal/ui/service-topology/_

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ ${
6464
const allowed = hasPerms ? false : fake.random.boolean();
6565
return `
6666
{
67+
${(Math.random(1) > 0.3) ? `
68+
"Kind": "${fake.helpers.randomize(['mesh-gateway', 'ingress-gateway', 'terminating-gateway', ''])}",
69+
` : ''}
6770
"Name": "${item.Name}",
6871
"Datacenter": "${item.Datacenter}",
6972
"Namespace": "${item.Namespace}",
@@ -87,6 +90,9 @@ ${
8790
const allowed = hasPerms ? false : fake.random.boolean();
8891
return `
8992
{
93+
${(Math.random(1) > 0.3) ? `
94+
"Kind": "${fake.helpers.randomize(['mesh-gateway', 'ingress-gateway', 'terminating-gateway', ''])}",
95+
` : ''}
9096
"Name": "${item.Name}",
9197
"Datacenter": "${item.Datacenter}",
9298
"Namespace": "${item.Namespace}",

ui/packages/consul-ui/translations/en-us.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,9 @@ components:
155155
name: Precedence
156156
asc: Ascending
157157
desc: Descending
158-
158+
topology-metrics:
159+
status:
160+
error: Unable to load metrics
161+
remote-dc: Unable to fetch metrics for a remote datacenter
162+
loading: Loading metrics
163+
ingress-gateway: Viewing metrics for Ingress Gateways is not currently supported in the UI.

0 commit comments

Comments
 (0)