Skip to content

Commit 425f744

Browse files
authored
Merge pull request ceph#51566 from rhcs-dashboard/fix-pool-application
mgr/dashboard: make application field for pool creation mandatory Reviewed-by: Pedro Gonzalez Gomez <[email protected]> Reviewed-by: afreen23 <NOT@FOUND> Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Nizamudeen A <[email protected]> Reviewed-by: Pere Diaz Bou <[email protected]> Reviewed-by: Sunil Angadi <[email protected]>
2 parents d2d079f + cd09538 commit 425f744

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,16 @@
171171
</div>
172172
<!-- Applications -->
173173
<div class="form-group row">
174-
<label i18n
175-
class="cd-col-form-label"
176-
for="applications">Applications</label>
174+
<label class="cd-col-form-label required"
175+
for="applications">
176+
<ng-container i18n>Applications</ng-container>
177+
<cd-helper>
178+
<span i18n>Pools need to be associated with an application before use</span>
179+
</cd-helper>
180+
</label>
177181
<div class="cd-col-form-input">
178182
<cd-select-badges id="applications"
183+
name="applications"
179184
[customBadges]="true"
180185
[customBadgeValidators]="data.applications.validators"
181186
[messages]="data.applications.messages"
@@ -189,6 +194,9 @@
189194
title="Pools should be associated with an application tag"
190195
class="{{icons.warning}} icon-warning-color">
191196
</i>
197+
<span class="invalid-feedback"
198+
*ngIf="!isApplicationsSelected && data.applications.selected <= 0"
199+
i18n>Application selection is required!</span>
192200
</div>
193201
</div>
194202
<!-- Mirroring -->

src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ describe('PoolFormComponent', () => {
10991099
// Mock that no ec profiles exist
11001100
infoReturn.erasure_code_profiles = [];
11011101
setUpPoolComponent();
1102+
component.data.applications.selected = ['cephfs', 'rgw'];
11021103
setMultipleValues({
11031104
name: 'minECPool',
11041105
poolType: 'erasure',
@@ -1108,37 +1109,46 @@ describe('PoolFormComponent', () => {
11081109
pool: 'minECPool',
11091110
pool_type: 'erasure',
11101111
pg_autoscale_mode: 'off',
1111-
pg_num: 4
1112+
pg_num: 4,
1113+
application_metadata: ['cephfs', 'rgw']
11121114
});
11131115
});
11141116

11151117
it('creates ec pool with erasure coded profile', () => {
1118+
component.data.applications.selected = ['cephfs', 'rgw'];
11161119
const ecp = { name: 'ecpMinimalMock' };
11171120
setMultipleValues({
11181121
erasureProfile: ecp
11191122
});
11201123
expectEcSubmit({
1121-
erasure_code_profile: ecp.name
1124+
erasure_code_profile: ecp.name,
1125+
application_metadata: ['cephfs', 'rgw']
11221126
});
11231127
});
11241128

11251129
it('creates ec pool with ec_overwrite flag', () => {
1130+
component.data.applications.selected = ['cephfs', 'rgw'];
11261131
setMultipleValues({
11271132
ecOverwrites: true
11281133
});
11291134
expectEcSubmit({
1130-
flags: ['ec_overwrites']
1135+
flags: ['ec_overwrites'],
1136+
application_metadata: ['cephfs', 'rgw']
11311137
});
11321138
});
11331139

11341140
it('should ignore replicated set settings for ec pools', () => {
1141+
component.data.applications.selected = ['cephfs', 'rgw'];
11351142
setMultipleValues({
11361143
size: 2 // will be ignored
11371144
});
1138-
expectEcSubmit({});
1145+
expectEcSubmit({
1146+
application_metadata: ['cephfs', 'rgw']
1147+
});
11391148
});
11401149

11411150
it('creates a pool with compression', () => {
1151+
component.data.applications.selected = ['cephfs', 'rgw'];
11421152
setMultipleValues({
11431153
mode: 'passive',
11441154
algorithm: 'lz4',
@@ -1151,7 +1161,8 @@ describe('PoolFormComponent', () => {
11511161
compression_algorithm: 'lz4',
11521162
compression_min_blob_size: 4096,
11531163
compression_max_blob_size: 4194304,
1154-
compression_required_ratio: 0.7
1164+
compression_required_ratio: 0.7,
1165+
application_metadata: ['cephfs', 'rgw']
11551166
});
11561167
});
11571168

@@ -1199,12 +1210,14 @@ describe('PoolFormComponent', () => {
11991210
size: 2,
12001211
pgNum: 32
12011212
});
1213+
component.data.applications.selected = ['cephfs', 'rgw'];
12021214
expectValidSubmit({
12031215
pool: 'minRepPool',
12041216
pool_type: 'replicated',
12051217
pg_num: 32,
12061218
pg_autoscale_mode: 'off',
1207-
size: 2
1219+
size: 2,
1220+
application_metadata: ['cephfs', 'rgw']
12081221
});
12091222
});
12101223

@@ -1218,8 +1231,10 @@ describe('PoolFormComponent', () => {
12181231
* if type `replicated` is set, pgNum will be set to 256 with the current rule for
12191232
* a replicated pool.
12201233
*/
1234+
component.data.applications.selected = ['cephfs', 'rgw'];
12211235
expectReplicatedSubmit({
1222-
pg_num: 256
1236+
pg_num: 256,
1237+
application_metadata: ['cephfs', 'rgw']
12231238
});
12241239
});
12251240

@@ -1228,20 +1243,24 @@ describe('PoolFormComponent', () => {
12281243
max_bytes: 1024 * 1024,
12291244
max_objects: 3000
12301245
});
1246+
component.data.applications.selected = ['cephfs', 'rgw'];
12311247
expectReplicatedSubmit({
12321248
quota_max_bytes: 1024 * 1024,
1233-
quota_max_objects: 3000
1249+
quota_max_objects: 3000,
1250+
application_metadata: ['cephfs', 'rgw']
12341251
});
12351252
});
12361253

12371254
it('creates a pool with rbd qos settings', () => {
12381255
component.currentConfigurationValues = {
12391256
rbd_qos_bps_limit: 55
12401257
};
1258+
component.data.applications.selected = ['cephfs', 'rgw'];
12411259
expectReplicatedSubmit({
12421260
configuration: {
12431261
rbd_qos_bps_limit: 55
1244-
}
1262+
},
1263+
application_metadata: ['cephfs', 'rgw']
12451264
});
12461265
});
12471266
});

src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class PoolFormComponent extends CdForm implements OnInit {
8686
ecpUsage: string[] = undefined; // Will only be set if a rule is used by some pool
8787
crushRuleMaxSize = 10;
8888
DEFAULT_RATIO = 0.875;
89+
isApplicationsSelected = true;
8990

9091
private modalSubscription: Subscription;
9192

@@ -860,6 +861,9 @@ export class PoolFormComponent extends CdForm implements OnInit {
860861
if (apps.includes('rbd')) {
861862
pool['rbd_mirroring'] = this.form.getValue('rbdMirroring');
862863
}
864+
this.isApplicationsSelected = true;
865+
} else {
866+
this.isApplicationsSelected = false;
863867
}
864868

865869
// 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 {
868872
pool['configuration'] = this.currentConfigurationValues;
869873
}
870874

875+
if (!this.isApplicationsSelected) {
876+
this.form.setErrors({ cdSubmitButton: true });
877+
return;
878+
}
879+
871880
this.triggerApiTask(pool);
872881
}
873882

0 commit comments

Comments
 (0)