]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fs rename only when fs is offline
authorNizamudeen A <nia@redhat.com>
Fri, 24 Nov 2023 08:45:39 +0000 (14:15 +0530)
committerNizamudeen A <nia@redhat.com>
Mon, 27 Nov 2023 14:11:02 +0000 (19:41 +0530)
and refuse_client_session is set

Fixes: https://tracker.ceph.com/issues/63608
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/controllers/cephfs.py
src/pybind/mgr/dashboard/frontend/cypress/e2e/filesystems/filesystems.e2e-spec.feature
src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.ts

index ed83f91d0c9737928358eb55ed5bb97275616ee6..a1066cbae0db652dcea334bcd51484b93b4cb604 100644 (file)
@@ -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
index 2c08fb56eff132b3513441ad6e0ee7acac919937..54fb1a8139e322edb0596745b4be60f5ce9321e0 100644 (file)
@@ -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"
index 38ae3a4affd0e80388de24335ab1545ca6a00d4b..2ba634fa25d0f6715efaefb83b161276c587619d 100644 (file)
@@ -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 }
           }
index 05235d16ccd44989977a88388c774245c342de8a..18db21f891f575049f40bf13adc9e325375a81d0 100644 (file)
                         i18n
                         *ngIf="!editing">Orchestrator is not configured. Deploy MDS daemons manually after creating the volume.</cd-alert-panel>
       </ng-container>
+
+      <cd-alert-panel type="info"
+                      class="m-3"
+                      spacingClass="mt-3"
+                      i18n
+                      *ngIf="editing && disableRename">
+        <p>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:</p>
+        <pre class="d-flex">{{ fsFailCmd }}
+          <cd-copy-2-clipboard-button [source]="fsFailCmd"
+                                      [byId]="false"
+                                      [showIconOnly]="true"></cd-copy-2-clipboard-button>
+        </pre>
+        <pre class="d-flex">{{ fsSetCmd }}
+          <cd-copy-2-clipboard-button [source]="fsSetCmd"
+                                      [byId]="false"
+                                      [showIconOnly]="true"></cd-copy-2-clipboard-button>
+        </pre>
+      </cd-alert-panel>
+
       <div class="card-body">
         <!-- Name -->
         <div class="form-group row">
         <cd-form-button-panel (submitActionEvent)="submit()"
                               [form]="form"
                               [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"
+                              [disabled]="editing ? disableRename: false"
                               wrappingClass="text-right"></cd-form-button-panel>
       </div>
     </div>
index 461f4bca052d85f49d0a2dceb925cdca770587a9..520f726d5553c57e99a1d2b5b0463d5daf78eefd 100644 (file)
@@ -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();
+    });
   });
 });
index 6d84e33c7b6145197c9c00eb3ab4ff57b1a43ae2..b0f90979c252b4b4b335eb5a7be702d5f470e57b 100644 (file)
@@ -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);
index 0d55845ab594912a7a1b2690fc3d195f9ea0150c..26e79727c12d185e2549e3de2232e5c5200fc7f5 100644 (file)
@@ -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',