]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Display the "destroyed" state in OSD list
authorTiago Melo <tmelo@suse.com>
Mon, 23 Sep 2019 13:15:35 +0000 (13:15 +0000)
committerTiago Melo <tmelo@suse.com>
Mon, 23 Sep 2019 15:52:10 +0000 (15:52 +0000)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts

index 7b2dcd69b31bdb68a1174d002f6097fc23246f3d..01c3a3f6fbc85931e73afc556c1b9de69bea31c5 100644 (file)
@@ -35,7 +35,7 @@
                  let-value="value">
       <span *ngFor="let state of value; last as last">
         <span class="badge"
-              [ngClass]="{'badge-success': ['in', 'up'].includes(state), 'badge-danger': ['down', 'out'].includes(state)}">{{ state }}</span>
+              [ngClass]="{'badge-success': ['in', 'up'].includes(state), 'badge-danger': ['down', 'out', 'destroyed'].includes(state)}">{{ state }}</span>
         <span *ngIf="!last">&nbsp;</span>
       </span>
     </ng-template>
index 59e82dcc14d205b91de95c37ed9e1f8de0022697..a26a34d713ad1ca1967c0d52fbc43d848410bb19 100644 (file)
@@ -4,7 +4,7 @@ import { ReactiveFormsModule } from '@angular/forms';
 import { By } from '@angular/platform-browser';
 import { RouterTestingModule } from '@angular/router/testing';
 
-import _ = require('lodash');
+import * as _ from 'lodash';
 import { BsModalService } from 'ngx-bootstrap/modal';
 import { TabsModule } from 'ngx-bootstrap/tabs';
 import { EMPTY, of } from 'rxjs';
@@ -129,7 +129,8 @@ describe('OsdListComponent', () => {
       stats: {
         stat_bytes_used: n * n,
         stat_bytes: n * n * n
-      }
+      },
+      state: []
     });
 
     const expectAttributeOnEveryOsd = (attr: string) =>
@@ -156,6 +157,15 @@ describe('OsdListComponent', () => {
       expect(component.osds[0].collectedStates).toEqual(['in', 'up']);
     });
 
+    it('should have "destroyed" state in "collectedStates"', () => {
+      osds[0].state.push('destroyed');
+      osds[0].up = 0;
+      component.getOsdList();
+
+      expectAttributeOnEveryOsd('collectedStates');
+      expect(component.osds[0].collectedStates).toEqual(['in', 'destroyed']);
+    });
+
     it('should have custom attribute "stats_history.out_bytes"', () => {
       expectAttributeOnEveryOsd('stats_history.out_bytes');
       expect(component.osds[0].stats_history.out_bytes).toEqual([1, 2]);
index abf6f2992f61897b5eed105729309159b20542be..103b0e20a9f8beafb93cc6377d70779990e2ce2e 100644 (file)
@@ -56,7 +56,15 @@ export class OsdListComponent implements OnInit {
   osds = [];
 
   protected static collectStates(osd) {
-    return [osd['in'] ? 'in' : 'out', osd['up'] ? 'up' : 'down'];
+    const states = [osd['in'] ? 'in' : 'out'];
+    if (osd['up']) {
+      states.push('up');
+    } else if (osd.state.includes('destroyed')) {
+      states.push('destroyed');
+    } else {
+      states.push('down');
+    }
+    return states;
   }
 
   constructor(