]> 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>
Fri, 13 Sep 2019 10:42:24 +0000 (12:42 +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>
(cherry picked from commit 789f9352ab426395f0b99270d27e0bd26b9075b3)

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 82acd606e09b16fac5ca08efc714dd02e8c3021d..12306801d8025fb62fea8d5be6186b92f5cf9a7b 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 ad050ef7ad08d1b11d7ca78285b9251b04a91a42..ad9dca78e350ea1776af275923722a3afeb3a288 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 297c75622a57dfb8a3b9de3ca8c71e563e7dd24c..2d3362b987d87d0d7bde644ed2a1c96b3d41cd88 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([