Skip to content

Commit

Permalink
mgr/dashboard: Use _no_schedule label instead of maintenance mode
Browse files Browse the repository at this point in the history
While adding a host in the cluster creation/expansion wizard, use the _no_schedule label instead of maintenance mode. With maintenance mode, we won't be able to create OSDs, or fetch the facts. The best alternate is to use the _no_schedule label. Thus using _no_schedule label instead.

Fixes: https://tracker.ceph.com/issues/52298
Signed-off-by: Nizamudeen A <nia@redhat.com>
  • Loading branch information
nizamial09 authored and Aashish Sharma committed Aug 20, 2021
1 parent 986707b commit c7bda38
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
Expand Up @@ -99,7 +99,10 @@ export class CreateClusterWizardHelper extends PageHelper {
}
}
cy.get('cd-modal cd-submit-button').click();
this.checkLabelExists(hostname, labels, add);
}

checkLabelExists(hostname: string, labels: string[], add: boolean) {
// Verify labels are added or removed from Labels column
// First find row with hostname, then find labels in the row
this.getTableCell(this.columnIndex.hostname, hostname)
Expand Down
Expand Up @@ -8,7 +8,7 @@ describe('Create cluster add host page', () => {
'ceph-node-02.cephlab.com'
];
const addHost = (hostname: string, exist?: boolean) => {
createCluster.add(hostname, exist, true);
createCluster.add(hostname, exist, false);
createCluster.checkExist(hostname, true);
};

Expand All @@ -25,13 +25,18 @@ describe('Create cluster add host page', () => {
cy.get('.title').should('contain.text', 'Add Hosts');
});

it('should check existing host and add new hosts into maintenance mode', () => {
it('should check existing host and add new hosts', () => {
createCluster.checkExist(hostnames[0], true);

addHost(hostnames[1], false);
addHost(hostnames[2], false);
});

it('should verify "_no_schedule" label is added', () => {
createCluster.checkLabelExists(hostnames[1], ['_no_schedule'], true);
createCluster.checkLabelExists(hostnames[2], ['_no_schedule'], true);
});

it('should not add an existing host', () => {
createCluster.add(hostnames[0], true);
});
Expand Down
Expand Up @@ -42,9 +42,9 @@ describe('when cluster creation is completed', () => {
beforeEach(() => {
hosts.navigateTo();
});
it('should have already exited from maintenance', () => {
it('should have removed "_no_schedule" label', () => {
for (let host = 0; host < hostnames.length; host++) {
cy.get('datatable-row-wrapper').should('not.have.text', 'maintenance');
cy.get('datatable-row-wrapper').should('not.have.text', '_no_schedule');
}
});

Expand Down
Expand Up @@ -129,8 +129,10 @@ export class CreateClusterComponent implements OnDestroy {
if (!this.stepsService.isLastStep()) {
this.hostService.list().subscribe((hosts) => {
hosts.forEach((host) => {
if (host['status'] === 'maintenance') {
this.observables.push(this.hostService.update(host['hostname'], false, [], true));
const index = host['labels'].indexOf('_no_schedule', 0);
if (index > -1) {
host['labels'].splice(index, 1);
this.observables.push(this.hostService.update(host['hostname'], true, host['labels']));
}
});
});
Expand Down
Expand Up @@ -25,7 +25,7 @@ export class HostFormComponent extends CdForm implements OnInit {
hostnames: string[];
addr: string;
status: string;
allLabels: any;
allLabels: string[];
pageURL: string;

messages = new SelectMessages({
Expand Down Expand Up @@ -60,7 +60,6 @@ export class HostFormComponent extends CdForm implements OnInit {
}

private createForm() {
const disableMaintenance = this.pageURL !== 'hosts';
this.hostForm = new CdFormGroup({
hostname: new FormControl('', {
validators: [
Expand All @@ -74,7 +73,7 @@ export class HostFormComponent extends CdForm implements OnInit {
validators: [CdValidators.ip()]
}),
labels: new FormControl([]),
maintenance: new FormControl({ value: disableMaintenance, disabled: disableMaintenance })
maintenance: new FormControl(false)
});
}

Expand All @@ -83,6 +82,9 @@ export class HostFormComponent extends CdForm implements OnInit {
this.addr = this.hostForm.get('addr').value;
this.status = this.hostForm.get('maintenance').value ? 'maintenance' : '';
this.allLabels = this.hostForm.get('labels').value;
if (this.pageURL !== 'hosts' && !this.allLabels.includes('_no_schedule')) {
this.allLabels.push('_no_schedule');
}
this.taskWrapper
.wrapTaskAroundCall({
task: new FinishedTask('host/' + URLVerbs.ADD, {
Expand Down
Expand Up @@ -115,21 +115,15 @@ export class HostsComponent extends ListWithDetails implements OnInit {
icon: Icons.enter,
click: () => this.hostMaintenance(),
disable: (selection: CdTableSelection) =>
this.getDisable('maintenance', selection) ||
this.isExecuting ||
this.enableButton ||
this.clusterCreation
this.getDisable('maintenance', selection) || this.isExecuting || this.enableButton
},
{
name: this.actionLabels.EXIT_MAINTENANCE,
permission: 'update',
icon: Icons.exit,
click: () => this.hostMaintenance(),
disable: (selection: CdTableSelection) =>
this.getDisable('maintenance', selection) ||
this.isExecuting ||
!this.enableButton ||
this.clusterCreation
this.getDisable('maintenance', selection) || this.isExecuting || !this.enableButton
}
];
}
Expand Down

0 comments on commit c7bda38

Please sign in to comment.