From: Pedro Gonzalez Gomez Date: Wed, 5 Apr 2023 15:42:52 +0000 (+0200) Subject: mgr/dashboard: rbd-mirror force promotion X-Git-Tag: v17.2.7~467^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F51057%2Fhead;p=ceph.git mgr/dashboard: rbd-mirror force promotion resolves: https://tracker.ceph.com/issues/59327 Signed-off-by: Pedro Gonzalez Gomez (cherry picked from commit 9696b6a04830297c23c4cccd6e7c225f183ba0b2) --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 40c7fef992bb..01e5b58c11bd 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -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) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts index 8b994d958a72..2eede58521f1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts @@ -9,6 +9,7 @@ export class RbdFormEditRequestModel { enable_mirror?: boolean; mirror_mode?: string; primary?: boolean; + force?: boolean; schedule_interval: string; remove_scheduling? = false; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html index 7ab53219ad56..75410c2ae038 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html @@ -132,3 +132,13 @@ title="RBD in status 'Removing'" class="{{ icons.warning }} warn"> + + + {{ errorMessage }} +
+ + Do you want to force the operation? + +
+
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index 79fad415e9e4..45f48b6f4dbf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -67,6 +67,8 @@ export class RbdListComponent extends ListWithDetails implements OnInit { provisionedNotAvailableTooltipTpl: TemplateRef; @ViewChild('totalProvisionedNotAvailableTooltipTpl', { static: true }) totalProvisionedNotAvailableTooltipTpl: TemplateRef; + @ViewChild('forcePromoteConfirmation', { static: true }) + forcePromoteConfirmation: TemplateRef; 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() { diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 20698c695af7..917963128955 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -566,6 +566,9 @@ paths: type: string features: type: string + force: + default: false + type: boolean mirror_mode: type: string name: