From: Stephan Müller Date: Thu, 25 Apr 2019 12:11:55 +0000 (+0200) Subject: mgr/dashboard: Allow the decrease of pg's of an existing pool X-Git-Tag: v15.1.0~2753^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=789f9352ab426395f0b99270d27e0bd26b9075b3;p=ceph.git mgr/dashboard: Allow the decrease of pg's of an existing pool Now it's possible to decrease the pg's of an existing pool. The decrease will take place over time like the increase. As for both no notification will be created when this is done (issue #39482). Fixes: https://tracker.ceph.com/issues/35917 Signed-off-by: Stephan Müller --- diff --git a/qa/tasks/mgr/dashboard/test_pool.py b/qa/tasks/mgr/dashboard/test_pool.py index 590c35160735..1cfe2fec36a5 100644 --- a/qa/tasks/mgr/dashboard/test_pool.py +++ b/qa/tasks/mgr/dashboard/test_pool.py @@ -235,7 +235,10 @@ class PoolTest(DashboardTestCase): # they can't recover from the resulting warning state. # Feel free to test it locally. # { - # 'pg_num': '8', + # 'pg_num': '2', # Decrease PGs + # }, + # { + # 'pg_num': '8', # Increase PGs # }, { 'application_metadata': ['rgw'], 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 623434b6e4f3..d6b3778d2089 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 @@ -97,10 +97,6 @@ Your cluster can't handle this many PGs. Please recalculate the PG amount needed. - You can only increase the number of PGs of an existing pool. - Currently your pool has {{ data.pool.pg_num }} PGs. { return control; }; + const testPgUpdate = (pgs, jump, returnValue) => { + if (pgs) { + setPgNum(pgs); + } + if (jump) { + setPgNum(form.getValue('pgNum') + jump); + } + expect(form.getValue('pgNum')).toBe(returnValue); + }; + const createCrushRule = ({ id = 0, name = 'somePoolName', @@ -260,7 +270,7 @@ describe('PoolFormComponent', () => { component.ngOnInit(); // Switches form into edit mode formHelper.setValue('poolType', 'erasure'); fixture.detectChanges(); - formHelper.expectError(setPgNum('8'), 'noDecrease'); + formHelper.expectValid(setPgNum('8')); }); it('is valid if pgNum, poolType and name are valid', () => { @@ -579,21 +589,6 @@ describe('PoolFormComponent', () => { }); describe('pg number changes', () => { - const setPgs = (pgs) => { - formHelper.setValue('pgNum', pgs); - fixture.debugElement.query(By.css('#pgNum')).nativeElement.dispatchEvent(new Event('blur')); - }; - - const testPgUpdate = (pgs, jump, returnValue) => { - if (pgs) { - setPgs(pgs); - } - if (jump) { - setPgs(form.getValue('pgNum') + jump); - } - expect(form.getValue('pgNum')).toBe(returnValue); - }; - beforeEach(() => { formHelper.setValue('crushRule', { min_size: 1, @@ -1050,9 +1045,14 @@ describe('PoolFormComponent', () => { expect(form.getValue('ratio')).toBe(pool.options.compression_required_ratio); }); - it('is only be possible to use the same or more pgs like before', () => { + it('updates pgs on every change', () => { + testPgUpdate(undefined, -1, 16); + testPgUpdate(undefined, -1, 8); + }); + + it('is possible to use less or more pgs than before', () => { formHelper.expectValid(setPgNum(64)); - formHelper.expectError(setPgNum(4), 'noDecrease'); + formHelper.expectValid(setPgNum(4)); }); describe('submit', () => { 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 7e944fc3e1ef..b6f57ee9a826 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 @@ -115,7 +115,7 @@ export class PoolFormComponent implements OnInit { this.form = new CdFormGroup( { name: new FormControl('', { - validators: [Validators.pattern(/^[\.A-Za-z0-9_/-]+$/), Validators.required] + validators: [Validators.pattern(/^[.A-Za-z0-9_/-]+$/), Validators.required] }), poolType: new FormControl('', { validators: [Validators.required] @@ -230,6 +230,7 @@ export class PoolFormComponent implements OnInit { this.form.silentSet(controlName, value); } }); + this.data.pgs = this.form.getValue('pgNum'); this.data.applications.selected = pool.application_metadata; } @@ -402,11 +403,6 @@ export class PoolFormComponent implements OnInit { private setComplexValidators() { if (this.editing) { - this.form - .get('pgNum') - .setValidators( - CdValidators.custom('noDecrease', (pgs) => this.data.pool && pgs < this.data.pool.pg_num) - ); this.form .get('name') .setValidators([