]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: check config option updatability also for bulk create 26450/head
authorTatjana Dehler <tdehler@suse.com>
Fri, 15 Feb 2019 15:55:20 +0000 (16:55 +0100)
committerTatjana Dehler <tdehler@suse.com>
Fri, 15 Feb 2019 16:00:43 +0000 (17:00 +0100)
Fixes: https://tracker.ceph.com/issues/34528
Signed-off-by: Tatjana Dehler <tdehler@suse.com>
qa/tasks/mgr/dashboard/test_cluster_configuration.py
src/pybind/mgr/dashboard/controllers/cluster_configuration.py

index 052c14bdeeaf9e81c46e6b52478c05a3054bdec0..fd9298f56bcb134930e177d76858971b2b4df179 100644 (file)
@@ -181,6 +181,54 @@ class ClusterConfigurationTest(DashboardTestCase):
             self._clear_all_values_for_config_option(config_name)
             self._reset_original_values(config_name, orig_values[config_name])
 
+    def test_bulk_set_cant_update_at_runtime(self):
+        config_options = {
+            'clog_to_syslog': {'section': 'global', 'value': 'true'},  # not updatable
+            'clog_to_graylog': {'section': 'global', 'value': 'true'}  # not updatable
+        }
+        orig_values = dict()
+
+        for config_name in config_options:
+            orig_values[config_name] = self._get_config_by_name(config_name)
+
+        # try to set config options and see if it fails
+        self._put('/api/cluster_conf', {'options': config_options})
+        self.assertStatus(400)
+        self.assertError(code='config_option_not_updatable_at_runtime',
+                         component='cluster_configuration',
+                         detail='Config option {} is/are not updatable at runtime'.format(
+                             ', '.join(config_options.keys())))
+
+        # check if config option values are still the original ones
+        for config_name, value in orig_values.items():
+            result = self._wait_for_expected_get_result(self._get_config_by_name, config_name,
+                                                        value)
+            self.assertEqual(result, value)
+
+    def test_bulk_set_cant_update_at_runtime_partial(self):
+        config_options = {
+            'clog_to_syslog': {'section': 'global', 'value': 'true'},  # not updatable
+            'log_to_stderr': {'section': 'global', 'value': 'true'}  # updatable
+        }
+        orig_values = dict()
+
+        for config_name in config_options:
+            orig_values[config_name] = self._get_config_by_name(config_name)
+
+        # try to set config options and see if it fails
+        self._put('/api/cluster_conf', {'options': config_options})
+        self.assertStatus(400)
+        self.assertError(code='config_option_not_updatable_at_runtime',
+                         component='cluster_configuration',
+                         detail='Config option {} is/are not updatable at runtime'.format(
+                             'clog_to_syslog'))
+
+        # check if config option values are still the original ones
+        for config_name, value in orig_values.items():
+            result = self._wait_for_expected_get_result(self._get_config_by_name, config_name,
+                                                        value)
+            self.assertEqual(result, value)
+
     def _validate_single(self, data):
         self.assertIn('name', data)
         self.assertIn('daemon_default', data)
index d6314024444c78a6c48c67b5b0a7c94e12573f65..fcf3f81914540fe18102c27c2f33ccb5b99fe93e 100644 (file)
@@ -40,12 +40,7 @@ class ClusterConfiguration(RESTController):
 
     def create(self, name, value):
         # Check if config option is updateable at runtime
-        config_option = self._get_config_option(name)
-        if not config_option['can_update_at_runtime']:
-            raise DashboardException(
-                msg='Config option {} is not updatable at runtime'.format(name),
-                code='config_option_not_updatable_at_runtime',
-                component='cluster_configuration')
+        self._updateable_at_runtime([name])
 
         # Update config option
         availSections = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']
@@ -63,6 +58,8 @@ class ClusterConfiguration(RESTController):
                 CephService.send_command('mon', 'config rm', who=section, name=name)
 
     def bulk_set(self, options):
+        self._updateable_at_runtime(options.keys())
+
         for name, value in options.items():
             CephService.send_command('mon', 'config set', who=value['section'],
                                      name=name, value=str(value['value']))
@@ -73,3 +70,18 @@ class ClusterConfiguration(RESTController):
                 return self._append_config_option_values([option])[0]
 
         raise cherrypy.HTTPError(404)
+
+    def _updateable_at_runtime(self, config_option_names):
+        not_updateable = []
+
+        for name in config_option_names:
+            config_option = self._get_config_option(name)
+            if not config_option['can_update_at_runtime']:
+                not_updateable.append(name)
+
+        if not_updateable:
+            raise DashboardException(
+                msg='Config option {} is/are not updatable at runtime'.format(
+                    ', '.join(not_updateable)),
+                code='config_option_not_updatable_at_runtime',
+                component='cluster_configuration')