Skip to content

Commit be1db6e

Browse files
authored
Merge pull request ceph#58143 from rhcs-dashboard/add-ec-profile-fields
mgr/dashboard: add fields to EC profile form Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Ankush Behl <[email protected]> Reviewed-by: Nizamudeen A <[email protected]>
2 parents ee41f85 + 8f7a5de commit be1db6e

File tree

7 files changed

+82
-2
lines changed

7 files changed

+82
-2
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form-modal.component.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,46 @@
252252
</div>
253253
</div>
254254

255+
<div class="form-group row">
256+
<label for="crushNumFailureDomains"
257+
class="cd-col-form-label">
258+
<ng-container i18n>Crush num failure domain</ng-container>
259+
<cd-helper [html]="tooltips.crushNumFailureDomains">
260+
</cd-helper>
261+
</label>
262+
<div class="cd-col-form-input">
263+
<input type="number"
264+
id="crushNumFailureDomains"
265+
name="crushNumFailureDomains"
266+
class="form-control"
267+
formControlName="crushNumFailureDomains"
268+
min="0">
269+
<span class="invalid-feedback"
270+
*ngIf="form.showError('crushNumFailureDomains', frm, 'required')"
271+
i18n>This field is required when crush osds per failure domain is set!</span>
272+
</div>
273+
</div>
274+
275+
<div class="form-group row">
276+
<label for="crushOsdsPerFailureDomain"
277+
class="cd-col-form-label">
278+
<ng-container i18n>Crush osds per failure domain</ng-container>
279+
<cd-helper [html]="tooltips.crushOsdsPerFailureDomain">
280+
</cd-helper>
281+
</label>
282+
<div class="cd-col-form-input">
283+
<input type="number"
284+
id="crushOsdsPerFailureDomain"
285+
name="crushOsdsPerFailureDomain"
286+
class="form-control"
287+
formControlName="crushOsdsPerFailureDomain"
288+
min="0">
289+
<span class="invalid-feedback"
290+
*ngIf="form.showError('crushOsdsPerFailureDomain', frm, 'required')"
291+
i18n>This field is required when crush num failure domain is set!</span>
292+
</div>
293+
</div>
294+
255295
<div class="form-group row"
256296
*ngIf="plugin === PLUGIN.LRC">
257297
<label for="crushLocality"

src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form-modal.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ export class ErasureCodeProfileFormModalComponent
8989
[Validators.required, CdValidators.custom('max', () => this.baseValueValidation())]
9090
],
9191
crushFailureDomain: '', // Will be preselected
92+
crushNumFailureDomains: [
93+
0,
94+
CdValidators.requiredIf({ crushOsdsPerFailureDomain: { op: 'minValue', arg1: 1 } })
95+
],
96+
crushOsdsPerFailureDomain: [
97+
0,
98+
CdValidators.requiredIf({ crushNumFailureDomains: { op: 'minValue', arg1: 1 } })
99+
],
92100
crushRoot: null, // Will be preselected
93101
crushDeviceClass: '', // Will be preselected
94102
directory: '',
@@ -448,6 +456,8 @@ export class ErasureCodeProfileFormModalComponent
448456
private extendJson(name: string, ecp: ErasureCodeProfile) {
449457
const differentApiAttributes = {
450458
crushFailureDomain: 'crush-failure-domain',
459+
crushNumFailureDomains: 'crush-num-failure-domains',
460+
crushOsdsPerFailureDomain: 'crush-osds-per-failure-domain',
451461
crushRoot: 'crush-root',
452462
crushDeviceClass: 'crush-device-class',
453463
packetSize: 'packetsize',

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@
234234
<select class="form-select"
235235
id="erasureProfile"
236236
name="erasureProfile"
237-
formControlName="erasureProfile">
237+
formControlName="erasureProfile"
238+
(change)="erasureProfileChange()">
238239
<option *ngIf="!ecProfiles"
239240
ngValue=""
240241
i18n>Loading...</option>
@@ -321,8 +322,14 @@
321322
for="crushRule"
322323
i18n>Crush ruleset</label>
323324
<div class="cd-col-form-input">
324-
<span class="form-text text-muted"
325+
<span *ngIf="!msrCrush; else msrCrushText"
326+
class="form-text text-muted"
325327
i18n>A new crush ruleset will be implicitly created.</span>
328+
<ng-template #msrCrushText>
329+
<span class="form-text text-muted"
330+
i18n>A new crush MSR ruleset will be implicitly created.
331+
When crush-osds-per-failure-domain or crush-num-failure-domains is specified</span>
332+
</ng-template>
326333
</div>
327334
</div>
328335
<div class="form-group row"

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class PoolFormComponent extends CdForm implements OnInit {
8787
crushRuleMaxSize = 10;
8888
DEFAULT_RATIO = 0.875;
8989
isApplicationsSelected = true;
90+
msrCrush: boolean = false;
9091

9192
private modalSubscription: Subscription;
9293

@@ -200,6 +201,7 @@ export class PoolFormComponent extends CdForm implements OnInit {
200201
this.listenToChanges();
201202
this.setComplexValidators();
202203
});
204+
this.erasureProfileChange();
203205
}
204206

205207
private initInfo(info: PoolFormInfo) {
@@ -943,4 +945,12 @@ export class PoolFormComponent extends CdForm implements OnInit {
943945
appSelection() {
944946
this.form.get('name').updateValueAndValidity({ emitEvent: false, onlySelf: true });
945947
}
948+
949+
erasureProfileChange() {
950+
const profile = this.form.get('erasureProfile').value;
951+
if (profile) {
952+
this.msrCrush =
953+
profile['crush-num-failure-domains'] > 0 || profile['crush-osds-per-failure-domain'] > 0;
954+
}
955+
}
946956
}

src/pybind/mgr/dashboard/frontend/src/app/shared/api/erasure-code-profile.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ export class ErasureCodeProfileService {
8484
domain. For instance, if the failure domain is host no two chunks will be stored on the same
8585
host. It is used to create a CRUSH rule step such as step chooseleaf host.`,
8686

87+
crushNumFailureDomains: $localize` Number of failure domains to map. Results in a CRUSH MSR rule being created.
88+
Must be specified if crush-osds-per-failure-domain is specified.`,
89+
90+
crushOsdsPerFailureDomain: $localize`Maximum number of OSDs to place in each failure domain --
91+
defaults to 1. Using a value greater than one will cause a CRUSH MSR rule to be created.
92+
Must be specified if crush-num-failure-domains is specified.`,
93+
8794
crushDeviceClass: $localize`Restrict placement to devices of a specific class
8895
(e.g., ssd or hdd), using the crush device class names in the CRUSH map.`,
8996

src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ export class CdValidators {
194194
result = value.length >= prerequisite['arg1'];
195195
}
196196
break;
197+
case 'minValue':
198+
if (_.isNumber(value)) {
199+
result = value >= prerequisite['arg1'];
200+
}
197201
}
198202
return result;
199203
}

src/pybind/mgr/dashboard/frontend/src/app/shared/models/erasure-code-profile.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export class ErasureCodeProfile {
1212
'crush-root'?: string;
1313
'crush-locality'?: string;
1414
'crush-failure-domain'?: string;
15+
'crush-num-failure-domains'?: number;
16+
'crush-osds-per-failure-domain'?: number;
1517
'crush-device-class'?: string;
1618
'directory'?: string;
1719
}

0 commit comments

Comments
 (0)