From 2c45ee9cfafc1e3aaf9210c7441ec3ca58ced714 Mon Sep 17 00:00:00 2001 From: Pedro Gonzalez Gomez Date: Tue, 25 Oct 2022 15:43:42 +0200 Subject: [PATCH] mgr/dashboard: bug fixes for rbd mirroring edit and promotion/demotion Signed-off-by: Pedro Gonzalez Gomez (cherry picked from commit b1b9d72b754e8d532614ad9d078f7ebedf4037d5) --- .../block/rbd-form/rbd-form.component.spec.ts | 18 ++++++++++++++++++ .../ceph/block/rbd-form/rbd-form.component.ts | 17 ++++++++--------- .../ceph/block/rbd-list/rbd-list.component.ts | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts index 5df73d93fe1e..7f7815c00ac9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts @@ -457,6 +457,24 @@ describe('RbdFormComponent', () => { expect(exclusiveLocks.checked).toBe(true); expect(exclusiveLocks.disabled).toBe(true); }); + + it('should have journaling feature for journaling mirror mode on createRequest', () => { + component.mirroring = true; + fixture.detectChanges(); + const journal = fixture.debugElement.query(By.css('#journal')).nativeElement; + expect(journal.checked).toBe(true); + const request = component.createRequest(); + expect(request.features).toContain('journaling'); + }); + + it('should have journaling feature for journaling mirror mode on editRequest', () => { + component.mirroring = true; + fixture.detectChanges(); + const journal = fixture.debugElement.query(By.css('#journal')).nativeElement; + expect(journal.checked).toBe(true); + const request = component.editRequest(); + expect(request.features).toContain('journaling'); + }); }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts index 4fa71646215f..f6c6af57947a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts @@ -690,18 +690,17 @@ export class RbdFormComponent extends CdForm implements OnInit { } }); request.enable_mirror = this.rbdForm.getValue('mirroring'); - if (this.poolMirrorMode === 'image') { - if (request.enable_mirror) { + if (request.enable_mirror) { + if (this.rbdForm.getValue('mirroringMode') === 'journal') { + request.features.push('journaling'); + } + if (this.poolMirrorMode === 'image') { request.mirror_mode = this.rbdForm.getValue('mirroringMode'); } } else { - if (request.enable_mirror) { - request.features.push('journaling'); - } else { - const index = request.features.indexOf('journaling', 0); - if (index > -1) { - request.features.splice(index, 1); - } + const index = request.features.indexOf('journaling', 0); + if (index > -1) { + request.features.splice(index, 1); } } request.configuration = this.getDirtyConfigurationValues(); 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 983f39ed9be5..a24e59f8203d 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 @@ -549,6 +549,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit { actionPrimary(primary: boolean) { const request = new RbdFormEditRequestModel(); request.primary = primary; + request.features = null; const imageSpec = new ImageSpec( this.selection.first().pool_name, this.selection.first().namespace, -- 2.47.3