From 55c2e483626b0897f5e4136d739ccd434ca0700b Mon Sep 17 00:00:00 2001 From: Pedro Gonzalez Gomez Date: Wed, 5 Apr 2023 17:42:52 +0200 Subject: [PATCH] mgr/dashboard: rbd-mirror force promotion resolves: https://tracker.ceph.com/issues/59327 Signed-off-by: Pedro Gonzalez Gomez (cherry picked from commit 9696b6a04830297c23c4cccd6e7c225f183ba0b2) --- src/pybind/mgr/dashboard/controllers/rbd.py | 4 +-- .../rbd-form/rbd-form-edit-request.model.ts | 1 + .../block/rbd-list/rbd-list.component.html | 10 +++++++ .../ceph/block/rbd-list/rbd-list.component.ts | 30 ++++++++++++++++++- src/pybind/mgr/dashboard/openapi.yaml | 3 ++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 728b2dc417936..523a9107fa642 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 8b994d958a724..2eede58521f1e 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 712d771c5d4e0..63f376962a065 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 @@ -126,3 +126,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 a24e59f8203d1..bfef485bf25db 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 @@ -65,6 +65,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[]; @@ -77,6 +79,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit { count = 0; private tableContext: CdTableFetchDataContext = null; modalRef: NgbModalRef; + errorMessage: string; builders = { 'rbd/create': (metadata: object) => @@ -562,7 +565,32 @@ export class RbdListComponent extends ListWithDetails implements OnInit { }), call: this.rbdService.update(imageSpec, request) }) - .subscribe(); + .subscribe( + /* tslint:disable:no-empty */ + () => {}, + (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 84b46e7879602..d2b429dd1cc99 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: -- 2.39.5