Skip to content

Commit

Permalink
mgr/dashboard: Add UI for Cluster-wide OSD Flags configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Melo <tmelo@suse.com>
  • Loading branch information
Tiago Melo committed Jun 18, 2018
1 parent 2d22939 commit 9fc6ff0
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import { ConfigurationComponent } from './configuration/configuration.component'
import { HostsComponent } from './hosts/hosts.component';
import { MonitorComponent } from './monitor/monitor.component';
import { OsdDetailsComponent } from './osd/osd-details/osd-details.component';
import { OsdFlagsModalComponent } from './osd/osd-flags-modal/osd-flags-modal.component';
import { OsdListComponent } from './osd/osd-list/osd-list.component';
import { OsdPerformanceHistogramComponent } from './osd/osd-performance-histogram/osd-performance-histogram.component';
import { OsdScrubModalComponent } from './osd/osd-scrub-modal/osd-scrub-modal.component';

@NgModule({
entryComponents: [OsdDetailsComponent, OsdScrubModalComponent],
entryComponents: [OsdDetailsComponent, OsdScrubModalComponent, OsdFlagsModalComponent],
imports: [
CommonModule,
PerformanceCounterModule,
Expand All @@ -37,7 +38,8 @@ import { OsdScrubModalComponent } from './osd/osd-scrub-modal/osd-scrub-modal.co
OsdListComponent,
OsdDetailsComponent,
OsdPerformanceHistogramComponent,
OsdScrubModalComponent
OsdScrubModalComponent,
OsdFlagsModalComponent
]
})
export class ClusterModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<cd-modal [modalRef]="bsModalRef">
<ng-container class="modal-title"
i18n>Cluster-wide OSD Flags
</ng-container>

<ng-container class="modal-content">
<form name="osdFlagsForm"
#formDir="ngForm"
[formGroup]="osdFlagsForm"
novalidate>
<div class="modal-body">
<div class="checkbox checkbox-primary"
*ngFor="let flag of flags; let last = last">
<input type="checkbox"
[checked]="flag.value"
(change)="flag.value = !flag.value"
[name]="flag.code"
[id]="flag.code"
[disabled]="flag.disabled">
<label [for]="flag.code"
ng-class="['tc_' + key]">
<strong>{{ flag.name }}</strong>
<br>
<span class="text-muted">{{ flag.description }}</span>
</label>
<hr class="oa-hr-small"
*ngIf="!last">
</div>
</div>

<div class="modal-footer">
<div class="button-group text-right">
<cd-submit-button (submitAction)="submitAction()"
[form]="osdFlagsForm"
i18n>
Submit
</cd-submit-button>

<button class="btn btn-link btn-sm"
(click)="bsModalRef.hide()"
i18n>
Cancel
</button>
</div>
</div>
</form>
</ng-container>
</cd-modal>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';

import { ToastModule } from 'ng2-toastr';
import { BsModalRef, ModalModule } from 'ngx-bootstrap';

import { SharedModule } from '../../../../shared/shared.module';
import { OsdFlagsModalComponent } from './osd-flags-modal.component';

describe('OsdFlagsModalComponent', () => {
let component: OsdFlagsModalComponent;
let fixture: ComponentFixture<OsdFlagsModalComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
ReactiveFormsModule,
ModalModule.forRoot(),
SharedModule,
HttpClientTestingModule,
ToastModule.forRoot()
],
declarations: [OsdFlagsModalComponent],
providers: [BsModalRef]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(OsdFlagsModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';

import * as _ from 'lodash';
import { BsModalRef } from 'ngx-bootstrap';

import { OsdService } from '../../../../shared/api/osd.service';
import { NotificationType } from '../../../../shared/enum/notification-type.enum';
import { NotificationService } from '../../../../shared/services/notification.service';

@Component({
selector: 'cd-osd-flags-modal',
templateUrl: './osd-flags-modal.component.html',
styleUrls: ['./osd-flags-modal.component.scss']
})
export class OsdFlagsModalComponent implements OnInit {
osdFlagsForm = new FormGroup({});

allFlags = {
noin: {
code: 'noin',
name: 'No In',
value: false,
description: 'OSDs that were previously marked out will not be marked back in when they start'
},
noout: {
code: 'noout',
name: 'No Out',
value: false,
description: 'OSDs will not automatically be marked out after the configured interval'
},
noup: {
code: 'noup',
name: 'No Up',
value: false,
description: 'OSDs are not allowed to start'
},
nodown: {
code: 'nodown',
name: 'No Down',
value: false,
description:
'OSD failure reports are being ignored, such that the monitors will not mark OSDs down'
},
pause: {
code: 'pause',
name: 'Pause',
value: false,
description: 'Pauses reads and writes'
},
noscrub: {
code: 'noscrub',
name: 'No Scrub',
value: false,
description: 'Scrubbing is disabled'
},
'nodeep-scrub': {
code: 'nodeep-scrub',
name: 'No Deep Scrub',
value: false,
description: 'Deep Scrubbing is disabled'
},
nobackfill: {
code: 'nobackfill',
name: 'No Backfill',
value: false,
description: 'Backfilling of PGs is suspended'
},
norecover: {
code: 'norecover',
name: 'No Recover',
value: false,
description: 'Recovery of PGs is suspended'
},
sortbitwise: {
code: 'sortbitwise',
name: 'Bitwise Sort',
value: true,
description: 'Use bitwise sort',
disabled: true
},
purged_snapdirs: {
code: 'purged_snapdirs',
name: 'Purged Snapdirs',
value: true,
description: 'OSDs have converted snapsets',
disabled: true
},
recovery_deletes: {
code: 'recovery_deletes',
name: 'Recovery Deletes',
value: true,
description: 'Deletes performed during recovery instead of peering',
disabled: true
}
};
flags: any[];
unknownFlags: string[] = [];

constructor(
public bsModalRef: BsModalRef,
private osdService: OsdService,
private notificationService: NotificationService
) {}

ngOnInit() {
this.osdService.getFlags().subscribe((res: string[]) => {
res.forEach((value) => {
if (this.allFlags[value]) {
this.allFlags[value].value = true;
} else {
this.unknownFlags.push(value);
}
});
this.flags = _.toArray(this.allFlags);
});
}

submitAction() {
const newFlags = this.flags
.filter((flag) => flag.value)
.map((flag) => flag.code)
.concat(this.unknownFlags);

this.osdService.updateFlags(newFlags).subscribe(
(res) => {
console.log(res);
this.notificationService.show(
NotificationType.success,
'OSD Flags were updated successfully.',
'OSD Flags'
);
this.bsModalRef.hide();
},
() => {
this.bsModalRef.hide();
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
selectionType="single"
(updateSelection)="updateSelection($event)"
[updateSelectionOnRefresh]="false">
<div class="table-actions">
<div class="table-actions btn-toolbar">
<div class="btn-group"
dropdown>
<button dropdownToggle
Expand Down Expand Up @@ -39,6 +39,14 @@
</li>
</ul>
</div>

<button class="btn btn-sm btn-default btn-label tc_configureCluster"
type="button"
(click)="configureClusterAction()">
<i class="fa fa-fw fa-cog"
aria-hidden="true"></i>
<ng-container i18n>Configure Cluster-wide OSD Flags</ng-container>
</button>
</div>

<cd-osd-details cdTableDetail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CellTemplate } from '../../../../shared/enum/cell-template.enum';
import { CdTableColumn } from '../../../../shared/models/cd-table-column';
import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
import { DimlessBinaryPipe } from '../../../../shared/pipes/dimless-binary.pipe';
import { OsdFlagsModalComponent } from '../osd-flags-modal/osd-flags-modal.component';
import { OsdScrubModalComponent } from '../osd-scrub-modal/osd-scrub-modal.component';

@Component({
Expand Down Expand Up @@ -91,4 +92,8 @@ export class OsdListComponent implements OnInit {

this.bsModalRef = this.modalService.show(OsdScrubModalComponent, { initialState });
}

configureClusterAction() {
this.bsModalRef = this.modalService.show(OsdFlagsModalComponent, {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ export class OsdService {
scrub(id, deep) {
return this.http.post(`${this.path}/${id}/scrub?deep=${deep}`, null);
}

getFlags() {
return this.http.get(`${this.path}/flags`);
}

updateFlags(flags: any) {
return this.http.put(`${this.path}/flags`, { flags: flags });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ import { ViewCacheComponent } from './view-cache/view-cache.component';
UsageBarComponent,
ModalComponent
],
entryComponents: [
ModalComponent,
DeletionModalComponent
]
entryComponents: [ModalComponent, DeletionModalComponent]
})
export class ComponentsModule { }
export class ComponentsModule {}

0 comments on commit 9fc6ff0

Please sign in to comment.