From f2cc24b94c5e8d8856797bd198dbb41907955ffb Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Fri, 24 Nov 2023 14:15:39 +0530 Subject: [PATCH] mgr/dashboard: fs rename only when fs is offline and refuse_client_session is set Fixes: https://tracker.ceph.com/issues/63608 Signed-off-by: Nizamudeen A --- .../mgr/dashboard/controllers/cephfs.py | 5 ++- .../filesystems/filesystems.e2e-spec.feature | 19 +++++----- .../frontend/src/app/app-routing.module.ts | 2 +- .../cephfs-form/cephfs-form.component.html | 21 +++++++++++ .../cephfs-form/cephfs-form.component.spec.ts | 37 +++++++++++++++++++ .../cephfs-form/cephfs-form.component.ts | 22 ++++++++++- .../cephfs-list/cephfs-list.component.ts | 2 +- 7 files changed, 94 insertions(+), 14 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/cephfs.py b/src/pybind/mgr/dashboard/controllers/cephfs.py index ed83f91d0c973..a1066cbae0db6 100644 --- a/src/pybind/mgr/dashboard/controllers/cephfs.py +++ b/src/pybind/mgr/dashboard/controllers/cephfs.py @@ -335,13 +335,16 @@ class CephFS(RESTController): standby_table = self.get_standby_table(fsmap['standbys'], mds_versions) + flags = mdsmap['flags_state'] + return { "cephfs": { "id": fs_id, "name": mdsmap['fs_name'], "client_count": client_count, "ranks": rank_table, - "pools": pools_table + "pools": pools_table, + "flags": flags, }, "standbys": standby_table, "versions": mds_versions diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/filesystems/filesystems.e2e-spec.feature b/src/pybind/mgr/dashboard/frontend/cypress/e2e/filesystems/filesystems.e2e-spec.feature index 2c08fb56eff13..54fb1a8139e32 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/filesystems/filesystems.e2e-spec.feature +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/filesystems/filesystems.e2e-spec.feature @@ -12,19 +12,20 @@ Feature: CephFS Management And I click on "Create File System" button Then I should see a row with "test_cephfs" - Scenario: Edit CephFS Volume - Given I am on the "cephfs" page - And I select a row "test_cephfs" - And I click on "Edit" button - And enter "name" "test_cephfs_edit" - And I click on "Edit File System" button - Then I should see a row with "test_cephfs_edit" + # Should be uncommented once the pre-requisite is fixed + # Scenario: Edit CephFS Volume + # Given I am on the "cephfs" page + # And I select a row "test_cephfs" + # And I click on "Edit" button + # And enter "name" "test_cephfs_edit" + # And I click on "Edit File System" button + # Then I should see a row with "test_cephfs_edit" Scenario: Remove CephFS Volume Given I am on the "cephfs" page - And I select a row "test_cephfs_edit" + And I select a row "test_cephfs" And I click on "Remove" button from the table actions Then I should see the modal And I check the tick box in modal And I click on "Remove File System" button - Then I should not see a row with "test_cephfs_edit" + Then I should not see a row with "test_cephfs" diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index 38ae3a4affd0e..2ba634fa25d0f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -361,7 +361,7 @@ const routes: Routes = [ data: { breadcrumbs: ActionLabels.CREATE } }, { - path: `${URLVerbs.EDIT}/:name`, + path: `${URLVerbs.EDIT}/:id`, component: CephfsVolumeFormComponent, data: { breadcrumbs: ActionLabels.EDIT } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html index 05235d16ccd44..18db21f891f57 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html @@ -15,6 +15,26 @@ i18n *ngIf="!editing">Orchestrator is not configured. Deploy MDS daemons manually after creating the volume. + + +

The File System can only be renamed if it is shutdown and `refuse_client_session` is set to true. + Follow the steps below in the command line and refresh the page:

+
{{ fsFailCmd }}
+          
+        
+
{{ fsSetCmd }}
+          
+        
+
+
@@ -98,6 +118,7 @@
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts index 461f4bca052d8..520f726d5553c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts @@ -78,5 +78,42 @@ describe('CephfsVolumeFormComponent', () => { expect(label).toBeNull(); expect(hosts).toBeNull(); }); + + it('should disable renaming and show info alert if disableRename is true', () => { + component.disableRename = true; + component.ngOnInit(); + fixture.detectChanges(); + const alertPanel = fixture.debugElement.query(By.css('cd-alert-panel')); + expect(alertPanel).not.toBeNull(); + }); + + it('should not show the alert if disableRename is false', () => { + component.disableRename = false; + component.ngOnInit(); + fixture.detectChanges(); + const alertPanel = fixture.debugElement.query(By.css('cd-alert-panel')); + expect(alertPanel).toBeNull(); + }); + + it('should disable the submit button only if disableRename is true', () => { + component.disableRename = true; + component.ngOnInit(); + fixture.detectChanges(); + const submitButton = fixture.debugElement.query(By.css('button[type=submit]')); + expect(submitButton.nativeElement.disabled).toBeTruthy(); + + // the submit button should only be disabled when the form is in edit mode + component.editing = false; + component.ngOnInit(); + fixture.detectChanges(); + expect(submitButton.nativeElement.disabled).toBeFalsy(); + + // submit button should be enabled if disableRename is false + component.editing = true; + component.disableRename = false; + component.ngOnInit(); + fixture.detectChanges(); + expect(submitButton.nativeElement.disabled).toBeFalsy(); + }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts index 6d84e33c7b614..b0f90979c252b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts @@ -51,6 +51,11 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit { labels: string[]; hasOrchestrator: boolean; currentVolumeName: string; + fsId: number; + disableRename: boolean = true; + + fsFailCmd: string; + fsSetCmd: string; constructor( private router: Router, @@ -101,9 +106,22 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit { ngOnInit() { if (this.editing) { - this.route.params.subscribe((params: { name: string }) => { - this.currentVolumeName = params.name; + this.route.params.subscribe((params: { id: string }) => { + this.fsId = Number(params.id); + }); + + this.cephfsService.getCephfs(this.fsId).subscribe((resp: object) => { + this.currentVolumeName = resp['cephfs']['name']; this.form.get('name').setValue(this.currentVolumeName); + + this.disableRename = !( + !resp['cephfs']['flags']['joinable'] && resp['cephfs']['flags']['refuse_client_session'] + ); + if (this.disableRename) { + this.form.get('name').disable(); + this.fsFailCmd = `ceph fs fail ${this.currentVolumeName}`; + this.fsSetCmd = `ceph fs set ${this.currentVolumeName} refuse_client_session true`; + } }); } else { const hostContext = new CdTableFetchDataContext(() => undefined); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts index 0d55845ab5949..26e79727c12d1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts @@ -87,7 +87,7 @@ export class CephfsListComponent extends ListWithDetails implements OnInit { permission: 'update', icon: Icons.edit, click: () => - this.router.navigate([this.urlBuilder.getEdit(this.selection.first().mdsmap.fs_name)]) + this.router.navigate([this.urlBuilder.getEdit(String(this.selection.first().id))]) }, { permission: 'delete', -- 2.39.5