]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Remove compression mode unset in pool from 31784/head
authorStephan Müller <smueller@suse.com>
Mon, 4 Nov 2019 17:57:05 +0000 (18:57 +0100)
committerAlfonso Martínez <almartin@redhat.com>
Thu, 21 Nov 2019 11:39:29 +0000 (12:39 +0100)
Somehow the compression mode "unset" was shown, but "unset" is only the
key that should be send to the backend in order to know that not
compression mode is selected ("none").

I also added some comments for better understanding.

Fixes: https://tracker.ceph.com/issues/42624
Signed-off-by: Stephan Müller <smueller@suse.com>
(cherry picked from commit dfb3ffc518f788c111f039bfc80c2d4a5251b2be)

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

index 3dc45aa7bd344fc373b36617edcc0170d26cb53b..0bc7ef2778fc949e8cc9f37b9888398f895dd927 100644 (file)
@@ -100,9 +100,9 @@ class Pool(RESTController):
 
     def _set_pool_values(self, pool, application_metadata, flags, update_existing, kwargs):
         update_name = False
-        if update_existing:
-            current_pool = self._get(pool)
-            self._handle_update_compression_args(current_pool.get('options'), kwargs)
+        current_pool = self._get(pool)
+        if update_existing and kwargs.get('compression_mode') == 'unset':
+            self._prepare_compression_removal(current_pool.get('options'), kwargs)
         if flags and 'ec_overwrites' in flags:
             CephService.send_command('mon', 'osd pool set', pool=pool, var='allow_ec_overwrites',
                                      val='true')
@@ -135,8 +135,18 @@ class Pool(RESTController):
         if update_name:
             CephService.send_command('mon', 'osd pool rename', srcpool=pool, destpool=destpool)
 
-    def _handle_update_compression_args(self, options, kwargs):
-        if kwargs.get('compression_mode') == 'unset' and options is not None:
+    def _prepare_compression_removal(self, options, kwargs):
+        """
+        Presets payload with values to remove compression attributes in case they are not
+        needed anymore.
+
+        In case compression is not needed the dashboard will send 'compression_mode' with the
+        value 'unset'.
+
+        :param options: All set options for the current pool.
+        :param kwargs: Payload of the PUT / POST call
+        """
+        if options is not None:
             def reset_arg(arg, value):
                 if options.get(arg):
                     kwargs[arg] = value
index a98b8c5877159533c3bc05f125f42c850fb9e0f9..c0cdecd46cc4d58725d5e1aa4dd0a21466364189 100644 (file)
@@ -168,7 +168,6 @@ export class PoolFormComponent implements OnInit {
 
   private initInfo(info: PoolFormInfo) {
     this.form.silentSet('algorithm', info.bluestore_compression_algorithm);
-    info.compression_modes.push('unset');
     this.info = info;
   }
 
@@ -580,7 +579,7 @@ export class PoolFormComponent implements OnInit {
             externalFieldName: 'compression_mode',
             formControlName: 'mode',
             editable: true,
-            replaceFn: () => 'unset'
+            replaceFn: () => 'unset' // Is used if no compression is set
           },
           {
             externalFieldName: 'srcpool',