From 96a9fbb2fc0329f78e8089b0bff2f0ef2e883cac Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Fri, 9 Jun 2023 09:38:55 -0400 Subject: [PATCH 1/2] Fix: dont show a service as healthy when its parent alloc is not running --- .changelog/17465.txt | 3 +++ ui/app/components/allocation-service-sidebar.hbs | 5 +++++ ui/app/components/allocation-service-sidebar.js | 1 + 3 files changed, 9 insertions(+) create mode 100644 .changelog/17465.txt diff --git a/.changelog/17465.txt b/.changelog/17465.txt new file mode 100644 index 000000000000..63977d8260c3 --- /dev/null +++ b/.changelog/17465.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: dont show a service as healthy when its parent allocation stops running +``` diff --git a/ui/app/components/allocation-service-sidebar.hbs b/ui/app/components/allocation-service-sidebar.hbs index c91bab1f9e0d..4c0881bd7050 100644 --- a/ui/app/components/allocation-service-sidebar.hbs +++ b/ui/app/components/allocation-service-sidebar.hbs @@ -20,6 +20,11 @@ {{#if (eq this.aggregateStatus 'Unhealthy')}} Unhealthy + {{else if (eq this.aggregateStatus 'Unknown')}} + + + Health Unknown + {{else}} Healthy diff --git a/ui/app/components/allocation-service-sidebar.js b/ui/app/components/allocation-service-sidebar.js index 3f84a9f50e53..6b6945e3f6b0 100644 --- a/ui/app/components/allocation-service-sidebar.js +++ b/ui/app/components/allocation-service-sidebar.js @@ -38,6 +38,7 @@ export default class AllocationServiceSidebarComponent extends Component { } get aggregateStatus() { + if (this.args.allocation?.clientStatus != -'running') return 'Unknown'; return this.checks.any((check) => check.Status === 'failure') ? 'Unhealthy' : 'Healthy'; From 70ef9b4534efac5b565dce7fcc75440e230ef7de Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Fri, 9 Jun 2023 09:50:38 -0400 Subject: [PATCH 2/2] Test for Health Unknown --- ui/app/components/allocation-service-sidebar.js | 2 +- .../components/allocation-service-sidebar-test.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/app/components/allocation-service-sidebar.js b/ui/app/components/allocation-service-sidebar.js index 6b6945e3f6b0..7ed9aff066d3 100644 --- a/ui/app/components/allocation-service-sidebar.js +++ b/ui/app/components/allocation-service-sidebar.js @@ -38,7 +38,7 @@ export default class AllocationServiceSidebarComponent extends Component { } get aggregateStatus() { - if (this.args.allocation?.clientStatus != -'running') return 'Unknown'; + if (this.args.allocation?.clientStatus !== 'running') return 'Unknown'; return this.checks.any((check) => check.Status === 'failure') ? 'Unhealthy' : 'Healthy'; diff --git a/ui/tests/integration/components/allocation-service-sidebar-test.js b/ui/tests/integration/components/allocation-service-sidebar-test.js index fa6145b3a739..0267b7cacf7f 100644 --- a/ui/tests/integration/components/allocation-service-sidebar-test.js +++ b/ui/tests/integration/components/allocation-service-sidebar-test.js @@ -76,7 +76,7 @@ module( }; this.set('closeSidebar', () => this.set('service', null)); - this.set('allocation', { id: 'myAlloc' }); + this.set('allocation', { id: 'myAlloc', clientStatus: 'running' }); this.set('service', healthyService); await render( hbs`` @@ -91,6 +91,13 @@ module( hbs`` ); assert.dom('h1 .aggregate-status').includesText('Unhealthy'); + + this.set('service', healthyService); + this.set('allocation', { id: 'myAlloc2', clientStatus: 'failed' }); + await render( + hbs`` + ); + assert.dom('h1 .aggregate-status').includesText('Health Unknown'); }); test('it handles Consul services with reduced functionality', async function (assert) {