]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rbd-mirror force promotion 51057/head
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Wed, 5 Apr 2023 15:42:52 +0000 (17:42 +0200)
committerPedro Gonzalez Gomez <pegonzal@li-870814cc-271e-11b2-a85c-b05660f70e90.ibm.com>
Wed, 12 Apr 2023 19:23:10 +0000 (21:23 +0200)
resolves: https://tracker.ceph.com/issues/59327
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
(cherry picked from commit 9696b6a04830297c23c4cccd6e7c225f183ba0b2)

src/pybind/mgr/dashboard/controllers/rbd.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts
src/pybind/mgr/dashboard/openapi.yaml

index 40c7fef992bbade3ddd8b87e2569d56526e18297..01e5b58c11bd372879344432387e88085a7a2692 100644 (file)
@@ -170,7 +170,7 @@ class Rbd(RESTController):
     @RbdTask('edit', ['{image_spec}', '{name}'], 4.0)
     def set(self, image_spec, name=None, size=None, features=None,
             configuration=None, enable_mirror=None, primary=None,
-            resync=False, mirror_mode=None, schedule_interval='',
+            force=False, resync=False, mirror_mode=None, schedule_interval='',
             remove_scheduling=False):
 
         pool_name, namespace, image_name = parse_image_spec(image_spec)
@@ -220,7 +220,7 @@ class Rbd(RESTController):
 
             if primary and not mirror_image_info['primary']:
                 RbdMirroringService.promote_image(
-                    image_name, pool_name, namespace)
+                    image_name, pool_name, namespace, force)
             elif primary is False and mirror_image_info['primary']:
                 RbdMirroringService.demote_image(
                     image_name, pool_name, namespace)
index 8b994d958a7246dbfcd67af3ab9da1203d7efd45..2eede58521f1e892ddb30f607aab7e947095ebcd 100644 (file)
@@ -9,6 +9,7 @@ export class RbdFormEditRequestModel {
   enable_mirror?: boolean;
   mirror_mode?: string;
   primary?: boolean;
+  force?: boolean;
   schedule_interval: string;
   remove_scheduling? = false;
 }
index 7ab53219ad560f60d6c9d07ee0fe862c81a2aaa3..75410c2ae03826a14ae46f09433a379a6465db0f 100644 (file)
      title="RBD in status 'Removing'"
      class="{{ icons.warning }} warn"></i>
 </ng-template>
+
+<ng-template #forcePromoteConfirmation>
+  <cd-alert-panel type="warning">{{ errorMessage }}</cd-alert-panel>
+  <div class="m-4"
+       i18n>
+    <strong>
+       Do you want to force the operation?
+    </strong>
+  </div>
+</ng-template>
index 79fad415e9e4b2b8079cf6727bec683779aa2b2a..45f48b6f4dbff78bc7e3f5336a246256db8b2e24 100644 (file)
@@ -67,6 +67,8 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
   provisionedNotAvailableTooltipTpl: TemplateRef<any>;
   @ViewChild('totalProvisionedNotAvailableTooltipTpl', { static: true })
   totalProvisionedNotAvailableTooltipTpl: TemplateRef<any>;
+  @ViewChild('forcePromoteConfirmation', { static: true })
+  forcePromoteConfirmation: TemplateRef<any>;
 
   permission: Permission;
   tableActions: CdTableAction[];
@@ -79,6 +81,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
   count = 0;
   private tableContext: CdTableFetchDataContext = null;
   modalRef: NgbModalRef;
+  errorMessage: string;
 
   builders = {
     'rbd/create': (metadata: object) =>
@@ -571,7 +574,31 @@ export class RbdListComponent extends ListWithDetails implements OnInit {
         }),
         call: this.rbdService.update(imageSpec, request)
       })
-      .subscribe();
+      .subscribe(
+        () => {},
+        (error) => {
+          if (primary) {
+            this.errorMessage = error.error['detail'].replace(/\[.*?\]\s*/, '');
+            request.force = true;
+            this.modalRef = this.modalService.show(ConfirmationModalComponent, {
+              titleText: $localize`Warning`,
+              buttonText: $localize`Enforce`,
+              warning: true,
+              bodyTpl: this.forcePromoteConfirmation,
+              onSubmit: () => {
+                this.rbdService.update(imageSpec, request).subscribe(
+                  () => {
+                    this.modalRef.close();
+                  },
+                  () => {
+                    this.modalRef.close();
+                  }
+                );
+              }
+            });
+          }
+        }
+      );
   }
 
   hasSnapshots() {
index 20698c695af7276b13ffc55a09e6d3f90b40ee3a..917963128955c894d16a00ddaa8c8036873b9ed5 100644 (file)
@@ -566,6 +566,9 @@ paths:
                   type: string
                 features:
                   type: string
+                force:
+                  default: false
+                  type: boolean
                 mirror_mode:
                   type: string
                 name: