Skip to content

Commit 5a44b39

Browse files
author
Aashish Sharma
committed
mgr/dashboard: Show which daemons failed in CEPHADM_FAILED_DAEMON
healthcheck Fixes: https://tracker.ceph.com/issues/63792 Signed-off-by: Aashish Sharma <[email protected]>
1 parent 37816ef commit 5a44b39

File tree

8 files changed

+114
-26
lines changed

8 files changed

+114
-26
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/upgrade/upgrade.component.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ <h5>{{ version }}</h5>
4747
id="clusterStatus">
4848
<div class="d-flex flex-column justify-content-center align-items-center">
4949
<ng-template #healthChecks>
50-
<ul>
51-
<li *ngFor="let check of healthData.health.checks">
52-
<span [ngStyle]="check.severity | healthColor"
53-
[class.health-warn-description]="check.severity === 'HEALTH_WARN'">
54-
{{ check.type }}</span>: {{ check.summary.message }}
55-
</li>
56-
</ul>
50+
<cd-health-checks [healthData]="healthData.health.checks"></cd-health-checks>
5751
</ng-template>
5852
<ng-template #healthWarningAndError>
5953
<div class="info-card-content-clickable mt-1"

src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard-v3/dashboard/dashboard-v3.component.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,8 @@
148148
</div>
149149
<div class="d-flex flex-column ms-4 me-4 mt-4 mb-4">
150150
<ng-template #healthChecks>
151-
<ng-container *ngTemplateOutlet="logsLink"></ng-container>
152-
<ul>
153-
<li *ngFor="let check of healthData.health.checks">
154-
<span [ngStyle]="check.severity | healthColor"
155-
[class.health-warn-description]="check.severity === 'HEALTH_WARN'">
156-
{{ check.type }}</span>: {{ check.summary.message }}
157-
</li>
158-
</ul>
151+
<cd-health-checks *ngIf="healthData?.health?.checks"
152+
[healthData]="healthData.health.checks"></cd-health-checks>
159153
</ng-template>
160154

161155
<div class="d-flex flex-row col-md-3 ms-4">
@@ -168,7 +162,7 @@
168162
popoverClass="info-card-popover-cluster-status"
169163
[openDelay]="300"
170164
[closeDelay]="500"
171-
triggers="mouseenter:mouseleave"
165+
triggers="mouseenter"
172166
*ngIf="healthData.health?.checks?.length"
173167
i18n>Cluster</a>
174168
<span class="ms-2 mt-n1 lead"

src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.html

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
*ngIf="healthData.health?.status">
1919
<ng-container *ngIf="healthData.health?.checks?.length > 0">
2020
<ng-template #healthChecks>
21-
<ng-container *ngTemplateOutlet="logsLink"></ng-container>
22-
<ul>
23-
<li *ngFor="let check of healthData.health.checks">
24-
<span [ngStyle]="check.severity | healthColor"
25-
[class.health-warn-description]="check.severity === 'HEALTH_WARN'">
26-
{{ check.type }}</span>: {{ check.summary.message }}
27-
</li>
28-
</ul>
21+
<cd-health-checks [healthData]="healthData"></cd-health-checks>
2922
</ng-template>
3023
<div class="info-card-content-clickable"
3124
[ngStyle]="healthData.health.status | healthColor"

src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/ceph-shared.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import { DataTableModule } from '~/app/shared/datatable/datatable.module';
88
import { SharedModule } from '~/app/shared/shared.module';
99
import { DeviceListComponent } from './device-list/device-list.component';
1010
import { SmartListComponent } from './smart-list/smart-list.component';
11+
import { HealthChecksComponent } from './health-checks/health-checks.component';
1112

1213
@NgModule({
1314
imports: [CommonModule, DataTableModule, SharedModule, NgbNavModule, NgxPipeFunctionModule],
14-
exports: [DeviceListComponent, SmartListComponent],
15-
declarations: [DeviceListComponent, SmartListComponent]
15+
exports: [DeviceListComponent, SmartListComponent, HealthChecksComponent],
16+
declarations: [DeviceListComponent, SmartListComponent, HealthChecksComponent]
1617
})
1718
export class CephSharedModule {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<ng-container *ngTemplateOutlet="logsLink"></ng-container>
2+
<ul>
3+
<li *ngFor="let check of healthData">
4+
<span [ngStyle]="check.severity | healthColor"
5+
[class.health-warn-description]="check.severity === 'HEALTH_WARN'">
6+
{{ check.type }}</span>: {{ check.summary.message }} <br>
7+
<div *ngIf="check.type === 'CEPHADM_FAILED_DAEMON'"
8+
class="failed-daemons">
9+
<cd-help-text>
10+
<b>Failed Daemons:</b>
11+
<div *ngFor="let failedDaemons of getFailedDaemons(check.detail); let last = last">
12+
{{ failedDaemons }}
13+
{{ !last ? ', ' : '' }}
14+
</div>
15+
</cd-help-text>
16+
</div>
17+
<div *ngFor="let details of check?.detail">
18+
<cd-help-text>{{ details?.message }}</cd-help-text>
19+
</div>
20+
</li>
21+
</ul>
22+
23+
<ng-template #logsLink>
24+
<ng-container *ngIf="permissions.log.read">
25+
<p class="logs-link"
26+
i18n><i [ngClass]="[icons.infoCircle]"></i> See <a routerLink="/logs">Logs</a> for more details.</p>
27+
</ng-container>
28+
</ng-template>

src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/health-checks/health-checks.component.scss

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { HealthChecksComponent } from './health-checks.component';
4+
import { HealthColorPipe } from '~/app/shared/pipes/health-color.pipe';
5+
import { By } from '@angular/platform-browser';
6+
import { CssHelper } from '~/app/shared/classes/css-helper';
7+
8+
describe('HealthChecksComponent', () => {
9+
let component: HealthChecksComponent;
10+
let fixture: ComponentFixture<HealthChecksComponent>;
11+
12+
beforeEach(async () => {
13+
await TestBed.configureTestingModule({
14+
declarations: [HealthChecksComponent, HealthColorPipe],
15+
providers: [CssHelper]
16+
}).compileComponents();
17+
18+
fixture = TestBed.createComponent(HealthChecksComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
27+
it('should show the correct health warning for failed daemons', () => {
28+
component.healthData = [
29+
{
30+
severity: 'HEALTH_WARN',
31+
summary: {
32+
message: '1 failed cephadm daemon(s)',
33+
count: 1
34+
},
35+
detail: [
36+
{
37+
message: 'daemon ceph-exporter.ceph-node-00 on ceph-node-00 is in error state'
38+
}
39+
],
40+
muted: false,
41+
type: 'CEPHADM_FAILED_DAEMON'
42+
}
43+
];
44+
fixture.detectChanges();
45+
const failedDaemons = fixture.debugElement.query(By.css('.failed-daemons'));
46+
expect(failedDaemons.nativeElement.textContent).toContain(
47+
'Failed Daemons: ceph-exporter.ceph-node-00 '
48+
);
49+
});
50+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Component, Input } from '@angular/core';
2+
import { Icons } from '~/app/shared/enum/icons.enum';
3+
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
4+
import { Permissions } from '~/app/shared/models/permissions';
5+
6+
@Component({
7+
selector: 'cd-health-checks',
8+
templateUrl: './health-checks.component.html',
9+
styleUrls: ['./health-checks.component.scss']
10+
})
11+
export class HealthChecksComponent {
12+
@Input()
13+
healthData: any;
14+
15+
icons = Icons;
16+
17+
permissions: Permissions;
18+
19+
constructor(private authStorageService: AuthStorageService) {
20+
this.permissions = this.authStorageService.getPermissions();
21+
}
22+
23+
getFailedDaemons(detail: any[]): string[] {
24+
return detail.map(
25+
(failedDaemons) => failedDaemons.message.split('daemon ')?.[1].split(' on ')[0]
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)