From 667d0026cde50db770979b0341ac918228cae9ae Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Fri, 9 Jun 2023 15:43:11 -0400 Subject: [PATCH] [ui] Don't show a service as healthy when its parent alloc is not running (#17465) * Fix: dont show a service as healthy when its parent alloc is not running * Test for Health Unknown --- .changelog/17465.txt | 3 +++ ui/app/components/allocation-service-sidebar.hbs | 5 +++++ ui/app/components/allocation-service-sidebar.js | 1 + .../components/allocation-service-sidebar-test.js | 9 ++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changelog/17465.txt diff --git a/.changelog/17465.txt b/.changelog/17465.txt new file mode 100644 index 000000000..63977d826 --- /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 c91bab1f9..4c0881bd7 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 3f84a9f50..7ed9aff06 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'; diff --git a/ui/tests/integration/components/allocation-service-sidebar-test.js b/ui/tests/integration/components/allocation-service-sidebar-test.js index fa6145b3a..0267b7cac 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) {