From 96204a21d8fa3a1778c0240081167b7fdfc2be43 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 11 Feb 2021 11:36:36 +0000 Subject: [PATCH] ui: [BUGFIX] Ensure we show the correct count of instances for each node (#9749) * Add MeshServiceInstances property to node model * Use MeshServiceInstances property * Make sure we show the 'No * checks' if Checks.length is zero --- .changelog/9749.txt | 3 +++ .../app/components/consul/instance-checks/index.hbs | 4 +--- .../consul-ui/app/components/consul/node/list/index.hbs | 2 +- ui/packages/consul-ui/app/models/node.js | 6 ++++++ .../consul-ui/app/templates/dc/nodes/show/services.hbs | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changelog/9749.txt diff --git a/.changelog/9749.txt b/.changelog/9749.txt new file mode 100644 index 0000000000..50b1d8922a --- /dev/null +++ b/.changelog/9749.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Exclude proxies when showing the total number of instances on a node. +``` diff --git a/ui/packages/consul-ui/app/components/consul/instance-checks/index.hbs b/ui/packages/consul-ui/app/components/consul/instance-checks/index.hbs index d6b06eb21d..2effe31c1b 100644 --- a/ui/packages/consul-ui/app/components/consul/instance-checks/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/instance-checks/index.hbs @@ -1,4 +1,3 @@ -{{#if (gt @items.length 0)}} {{#if (eq this.healthCheck.check 'empty') }}
@@ -28,5 +27,4 @@
{{this.healthCheck.count}}/{{@items.length}} {{@type}} checks {{this.healthCheck.status}}
{{/if}} - {{/if}} -{{/if}} \ No newline at end of file + {{/if}} \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/node/list/index.hbs b/ui/packages/consul-ui/app/components/consul/node/list/index.hbs index c568346d8e..b4ff074252 100644 --- a/ui/packages/consul-ui/app/components/consul/node/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/node/list/index.hbs @@ -30,7 +30,7 @@ as |item index|> Leader {{/if}} - {{format-number item.Services.length}} {{pluralize item.Services.length 'Service' without-count=true}} + {{format-number item.MeshServiceInstances.length}} {{pluralize item.MeshServiceInstances.length 'Service' without-count=true}}
diff --git a/ui/packages/consul-ui/app/models/node.js b/ui/packages/consul-ui/app/models/node.js index 2c77cd9798..58801c24fa 100644 --- a/ui/packages/consul-ui/app/models/node.js +++ b/ui/packages/consul-ui/app/models/node.js @@ -1,5 +1,6 @@ import Model, { attr, hasMany } from '@ember-data/model'; import { computed } from '@ember/object'; +import { filter } from '@ember/object/computed'; import { fragmentArray } from 'ember-data-model-fragments/attributes'; export const PRIMARY_KEY = 'uid'; @@ -18,8 +19,13 @@ export default class Node extends Model { @attr() meta; // {} @attr() Meta; // {} @attr() TaggedAddresses; // {lan, wan} + // Services are reshaped to a different shape to what you sometimes get from + // the response, see models/node.js @hasMany('service-instance') Services; // TODO: Rename to ServiceInstances @fragmentArray('health-check') Checks; + // MeshServiceInstances are all instances that aren't connect-proxies this + // currently includes gateways as these need to show up in listings + @filter('Services', item => item.Service.Kind !== 'connect-proxy') MeshServiceInstances; @computed('Checks.[]', 'ChecksCritical', 'ChecksPassing', 'ChecksWarning') get Status() { diff --git a/ui/packages/consul-ui/app/templates/dc/nodes/show/services.hbs b/ui/packages/consul-ui/app/templates/dc/nodes/show/services.hbs index 1d1000fa68..68b0ff9ecc 100644 --- a/ui/packages/consul-ui/app/templates/dc/nodes/show/services.hbs +++ b/ui/packages/consul-ui/app/templates/dc/nodes/show/services.hbs @@ -24,7 +24,7 @@ ) ) - (reject-by 'Service.Kind' 'connect-proxy' item.Services) + item.MeshServiceInstances as |sort filters items|}}