]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: rbd-mirror force promotion
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>
Tue, 11 Apr 2023 11:53:23 +0000 (13:53 +0200)
resolves: https://tracker.ceph.com/issues/59327
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
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 f3c25ca50891eb0cb82f21e0f920d2639c80ce17..de94a4802d16ae3c6c884e1edd8d6eaa4d1b385d 100644 (file)
@@ -179,7 +179,7 @@ class Rbd(RESTController):
     @RbdTask('edit', ['{image_spec}', '{name}'], 4.0)
     def set(self, image_spec, name=None, size=None, features=None,
             configuration=None, metadata=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)
@@ -231,7 +231,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 49c9334f65d983ce38bcfbaba1eb34bfd46b5060..b16fc4190d87f79ad9b41527d1466a37da11c375 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 47f7c6728cb4654115fb1f58c032a90dbff76090..72994cab1e36a7a6ceedd0797f1dd808c70d1bc6 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 dfb30d3a309b1461f93ff706bd2b36629d8af685..8230e7c17fc39a5b47f1805e2cd9370b76833103 100644 (file)
@@ -568,6 +568,9 @@ paths:
                   type: string
                 features:
                   type: string
+                force:
+                  default: false
+                  type: boolean
                 metadata:
                   type: string
                 mirror_mode: