]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Allow the decrease of pg's of an existing pool
authorStephan Müller <smueller@suse.com>
Thu, 25 Apr 2019 12:11:55 +0000 (14:11 +0200)
committerStephan Müller <smueller@suse.com>
Mon, 29 Apr 2019 14:44:27 +0000 (16:44 +0200)
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 <smueller@suse.com>
qa/tasks/mgr/dashboard/test_pool.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts

index 590c351607352cde1633ebcf3938406a76e3a89b..1cfe2fec36a5db43d77603f002e94c221a596805 100644 (file)
@@ -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'],
index 623434b6e4f33f138972e421fb5465eed1289f47..d6b3778d2089efd30496d7580d3e75c23b385b5e 100644 (file)
               <span class="help-block"
                     *ngIf="form.showError('pgNum', formDir, '34')"
                     i18n>Your cluster can't handle this many PGs. Please recalculate the PG amount needed.</span>
-              <span class="help-block"
-                    *ngIf="form.showError('pgNum', formDir, 'noDecrease')"
-                    i18n>You can only increase the number of PGs of an existing pool.
-                Currently your pool has {{ data.pool.pg_num }} PGs.</span>
               <span class="help-block">
                 <a i18n
                    target="_blank"
index 7f78a0ef4f054e7cc646d7bd3965caf05869c043..51e4e3f1ed5ea6823a000b60ab6e82309e499db9 100644 (file)
@@ -48,6 +48,16 @@ describe('PoolFormComponent', () => {
     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', () => {
index 7e944fc3e1ef92d45cd70078a544c978fd8d1e47..b6f57ee9a8266358101bdafdb9b7ef834e0ca9e8 100644 (file)
@@ -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([