From cd09538c62a57c49c1f4a8b41811e38f29932129 Mon Sep 17 00:00:00 2001 From: avanthakkar Date: Thu, 18 May 2023 17:44:50 +0530 Subject: [PATCH] mgr/dashboard: make application field for pool creation mandatory Fixes: https://tracker.ceph.com/issues/61238 Signed-off-by: avanthakkar --- .../pool/pool-form/pool-form.component.html | 14 +++++-- .../pool-form/pool-form.component.spec.ts | 37 ++++++++++++++----- .../pool/pool-form/pool-form.component.ts | 9 +++++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html index d3176b61dfd..fbd5fe0ccda 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html @@ -171,11 +171,16 @@
- +
+ Application selection is required!
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts index 5556e4b2df4..caf8c0b6a71 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts @@ -1099,6 +1099,7 @@ describe('PoolFormComponent', () => { // Mock that no ec profiles exist infoReturn.erasure_code_profiles = []; setUpPoolComponent(); + component.data.applications.selected = ['cephfs', 'rgw']; setMultipleValues({ name: 'minECPool', poolType: 'erasure', @@ -1108,37 +1109,46 @@ describe('PoolFormComponent', () => { pool: 'minECPool', pool_type: 'erasure', pg_autoscale_mode: 'off', - pg_num: 4 + pg_num: 4, + application_metadata: ['cephfs', 'rgw'] }); }); it('creates ec pool with erasure coded profile', () => { + component.data.applications.selected = ['cephfs', 'rgw']; const ecp = { name: 'ecpMinimalMock' }; setMultipleValues({ erasureProfile: ecp }); expectEcSubmit({ - erasure_code_profile: ecp.name + erasure_code_profile: ecp.name, + application_metadata: ['cephfs', 'rgw'] }); }); it('creates ec pool with ec_overwrite flag', () => { + component.data.applications.selected = ['cephfs', 'rgw']; setMultipleValues({ ecOverwrites: true }); expectEcSubmit({ - flags: ['ec_overwrites'] + flags: ['ec_overwrites'], + application_metadata: ['cephfs', 'rgw'] }); }); it('should ignore replicated set settings for ec pools', () => { + component.data.applications.selected = ['cephfs', 'rgw']; setMultipleValues({ size: 2 // will be ignored }); - expectEcSubmit({}); + expectEcSubmit({ + application_metadata: ['cephfs', 'rgw'] + }); }); it('creates a pool with compression', () => { + component.data.applications.selected = ['cephfs', 'rgw']; setMultipleValues({ mode: 'passive', algorithm: 'lz4', @@ -1151,7 +1161,8 @@ describe('PoolFormComponent', () => { compression_algorithm: 'lz4', compression_min_blob_size: 4096, compression_max_blob_size: 4194304, - compression_required_ratio: 0.7 + compression_required_ratio: 0.7, + application_metadata: ['cephfs', 'rgw'] }); }); @@ -1199,12 +1210,14 @@ describe('PoolFormComponent', () => { size: 2, pgNum: 32 }); + component.data.applications.selected = ['cephfs', 'rgw']; expectValidSubmit({ pool: 'minRepPool', pool_type: 'replicated', pg_num: 32, pg_autoscale_mode: 'off', - size: 2 + size: 2, + application_metadata: ['cephfs', 'rgw'] }); }); @@ -1218,8 +1231,10 @@ describe('PoolFormComponent', () => { * if type `replicated` is set, pgNum will be set to 256 with the current rule for * a replicated pool. */ + component.data.applications.selected = ['cephfs', 'rgw']; expectReplicatedSubmit({ - pg_num: 256 + pg_num: 256, + application_metadata: ['cephfs', 'rgw'] }); }); @@ -1228,9 +1243,11 @@ describe('PoolFormComponent', () => { max_bytes: 1024 * 1024, max_objects: 3000 }); + component.data.applications.selected = ['cephfs', 'rgw']; expectReplicatedSubmit({ quota_max_bytes: 1024 * 1024, - quota_max_objects: 3000 + quota_max_objects: 3000, + application_metadata: ['cephfs', 'rgw'] }); }); @@ -1238,10 +1255,12 @@ describe('PoolFormComponent', () => { component.currentConfigurationValues = { rbd_qos_bps_limit: 55 }; + component.data.applications.selected = ['cephfs', 'rgw']; expectReplicatedSubmit({ configuration: { rbd_qos_bps_limit: 55 - } + }, + application_metadata: ['cephfs', 'rgw'] }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts index a87aa6c019b..ed8bda277fd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts @@ -86,6 +86,7 @@ export class PoolFormComponent extends CdForm implements OnInit { ecpUsage: string[] = undefined; // Will only be set if a rule is used by some pool crushRuleMaxSize = 10; DEFAULT_RATIO = 0.875; + isApplicationsSelected = true; private modalSubscription: Subscription; @@ -860,6 +861,9 @@ export class PoolFormComponent extends CdForm implements OnInit { if (apps.includes('rbd')) { pool['rbd_mirroring'] = this.form.getValue('rbdMirroring'); } + this.isApplicationsSelected = true; + } else { + this.isApplicationsSelected = false; } // Only collect configuration data for replicated pools, as QoS cannot be configured on EC @@ -868,6 +872,11 @@ export class PoolFormComponent extends CdForm implements OnInit { pool['configuration'] = this.currentConfigurationValues; } + if (!this.isApplicationsSelected) { + this.form.setErrors({ cdSubmitButton: true }); + return; + } + this.triggerApiTask(pool); } -- 2.39.5