]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rbd force resync from fornt-end
authorSarthak0702 <sarthak.dev.0702@gmail.com>
Thu, 2 Jun 2022 22:58:31 +0000 (04:28 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 16 Aug 2022 07:31:16 +0000 (13:01 +0530)
Resolves: rhbz#1891012

Signed-off-by: Sarthak0702 <sarthak.dev.0702@gmail.com>
(cherry picked from commit 2b005395818700185e2c0f7713fae0c321471b2d)

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts

index a63ac2379fd59677be3b3fb93e5a9e9084ad2bd4..c6dde029233d649abf63adc1aa5b5ef509b656b3 100644 (file)
@@ -319,6 +319,7 @@ describe('RbdListComponent', () => {
           'Edit',
           'Copy',
           'Flatten',
+          'Resync',
           'Delete',
           'Move to Trash',
           'Remove Scheduling'
@@ -326,7 +327,7 @@ describe('RbdListComponent', () => {
         primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
       },
       'create,update': {
-        actions: ['Create', 'Edit', 'Copy', 'Flatten', 'Remove Scheduling'],
+        actions: ['Create', 'Edit', 'Copy', 'Flatten', 'Resync', 'Remove Scheduling'],
         primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' }
       },
       'create,delete': {
@@ -338,11 +339,11 @@ describe('RbdListComponent', () => {
         primary: { multiple: 'Create', executing: 'Copy', single: 'Copy', no: 'Create' }
       },
       'update,delete': {
-        actions: ['Edit', 'Flatten', 'Delete', 'Move to Trash', 'Remove Scheduling'],
+        actions: ['Edit', 'Flatten', 'Resync', 'Delete', 'Move to Trash', 'Remove Scheduling'],
         primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
       },
       update: {
-        actions: ['Edit', 'Flatten', 'Remove Scheduling'],
+        actions: ['Edit', 'Flatten', 'Resync', 'Remove Scheduling'],
         primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' }
       },
       delete: {
index c77a627324eedd255c224fde284cf418985775d3..215f7f6f874ac8f29e9f3f96b7a57ad229900a50 100644 (file)
@@ -153,6 +153,13 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
       name: this.actionLabels.DELETE,
       disable: (selection: CdTableSelection) => this.getDeleteDisableDesc(selection)
     };
+    const resyncAction: CdTableAction = {
+      permission: 'update',
+      icon: Icons.refresh,
+      click: () => this.resyncRbdModal(),
+      name: this.actionLabels.RESYNC,
+      disable: (selection: CdTableSelection) => this.getResyncDisableDesc(selection)
+    };
     const copyAction: CdTableAction = {
       permission: 'create',
       canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection,
@@ -200,6 +207,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
       editAction,
       copyAction,
       flattenAction,
+      resyncAction,
       deleteAction,
       moveAction,
       removeSchedulingAction
@@ -411,6 +419,26 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
     });
   }
 
+  resyncRbdModal() {
+    const poolName = this.selection.first().pool_name;
+    const namespace = this.selection.first().namespace;
+    const imageName = this.selection.first().name;
+    const imageSpec = new ImageSpec(poolName, namespace, imageName);
+
+    this.modalRef = this.modalService.show(CriticalConfirmationModalComponent, {
+      itemDescription: 'RBD',
+      itemNames: [imageSpec],
+      actionDescription: 'resync',
+      submitActionObservable: () =>
+        this.taskWrapper.wrapTaskAroundCall({
+          task: new FinishedTask('rbd/edit', {
+            image_spec: imageSpec.toString()
+          }),
+          call: this.rbdService.update(imageSpec, { resync: true })
+        })
+    });
+  }
+
   trashRbdModal() {
     const initialState = {
       poolName: this.selection.first().pool_name,
@@ -533,6 +561,19 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
     return this.getInvalidNameDisable(selection) || this.hasClonedSnapshots(selection.first());
   }
 
+  getResyncDisableDesc(selection: CdTableSelection): string | boolean {
+    const first = selection.first();
+
+    if (first && this.imageIsPrimary(first)) {
+      return $localize`Primary RBD images cannot be resynced`;
+    }
+
+    return this.getInvalidNameDisable(selection);
+  }
+
+  imageIsPrimary(image: object) {
+    return image['primary'];
+  }
   getInvalidNameDisable(selection: CdTableSelection): string | boolean {
     const first = selection.first();
 
index dfa25475bc72c076255f17576d97d4ab9eb68fa2..40d12653ea6b58c82e8b00ac118428aaa90e6d6e 100644 (file)
@@ -137,6 +137,7 @@ export class ActionLabelsI18n {
   STOP: string;
   REDEPLOY: string;
   RESTART: string;
+  RESYNC: string;
 
   constructor() {
     /* Create a new item */
@@ -193,7 +194,7 @@ export class ActionLabelsI18n {
 
     this.START_DRAIN = $localize`Start Drain`;
     this.STOP_DRAIN = $localize`Stop Drain`;
-
+    this.RESYNC = $localize`Resync`;
     /* Prometheus wording */
     this.RECREATE = $localize`Recreate`;
     this.EXPIRE = $localize`Expire`;