]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/diskprediction: use global device_failure_prediction_mode setting 24755/head
authorSage Weil <sage@redhat.com>
Thu, 25 Oct 2018 13:30:49 +0000 (08:30 -0500)
committerSage Weil <sage@redhat.com>
Mon, 29 Oct 2018 13:44:17 +0000 (08:44 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
doc/mgr/diskprediction.rst
src/common/options.cc
src/pybind/mgr/diskprediction/module.py

index 7c25cfbb9e458b7705e9c8749a7effadccc2a6e0..f0778e193cb0e50ce490f3185a4d58562e2d27e3 100644 (file)
@@ -10,18 +10,22 @@ Enabling
 ========
 
 Run the following command to enable the *diskprediction* module in the Ceph
-environment:
-
-::
+environment::
 
     ceph mgr module enable diskprediction
 
 
-Select the prediction mode:
+Select the prediction mode::
 
-::
+    ceph config set global device_health_prediction_mode local
+
+or::
+  
+    ceph config set global device_health_prediction_mode cloud
+
+To disable prediction,::
 
-    ceph device set-prediction-mode <local/cloud>
+  ceph config set global device_health_prediction_mode none
 
 
 Connection settings
index ac855ed7561d16016c5daef7e207b92721b23dee..b60b7ed8700a77db883b5235f4f36c7d763ad4eb 100644 (file)
@@ -4988,6 +4988,14 @@ std::vector<Option> get_global_options() {
     Option("target_max_misplaced_ratio", Option::TYPE_FLOAT, Option::LEVEL_BASIC)
     .set_default(.05)
     .set_description("Max ratio of misplaced objects to target when throttling data rebalancing activity"),
+
+    Option("device_failure_prediction_mode", Option::TYPE_STR, Option::LEVEL_BASIC)
+    .set_default("none")
+    .set_enum_allowed({"none", "local", "cloud"})
+    .set_description("Method used to predict device failures")
+    .set_long_description("To disable prediction, use 'none',  'local' uses a prediction model that runs inside the mgr daemon.  'cloud' will share metrics with a cloud service and query the service for devicelife expectancy."),
+
+
   });
 }
 
index 4ae2a7976a17b2a9de3d4d9b913b333115f2561a..1edac76531b3fa88ebf34005b7ad982f3f0a73b8 100644 (file)
@@ -20,10 +20,6 @@ DP_AGENTS = [MetricsRunner, SmartRunner, PredictionRunner]
 class Module(MgrModule):
 
     OPTIONS = [
-        {
-            'name': 'diskprediction_config_mode',
-            'default': 'local'
-        },
         {
             'name': 'diskprediction_server',
             'default': ''
@@ -67,12 +63,6 @@ class Module(MgrModule):
     ]
 
     COMMANDS = [
-        {
-            'cmd': 'device set-prediction-mode '
-                   'name=mode,type=CephString,req=true',
-            'desc': 'config disk prediction mode [\"cloud\"|\"local\"]',
-            'perm': 'rw'
-        },
         {
             'cmd': 'device show-prediction-config',
             'desc': 'Prints diskprediction configuration',
@@ -168,21 +158,6 @@ class Module(MgrModule):
         self.show_module_config()
         return 0, json.dumps(self.config, indent=4), ''
 
-    def _set_prediction_mode(self, inbuf, cmd):
-        self.status = {}
-        str_mode = cmd.get('mode', 'cloud')
-        if str_mode.lower() not in ['cloud', 'local']:
-            return -errno.EINVAL, '', 'invalid configuration, enable=[cloud|local]'
-        try:
-            self.set_config('diskprediction_config_mode', str_mode)
-            for _agent in self._agents:
-                _agent.event.set()
-            return (0,
-                    'success to config disk prediction mode: %s'
-                    % str_mode.lower(), 0)
-        except Exception as e:
-            return -errno.EINVAL, '', str(e)
-
     def _self_test(self, inbuf, cmd):
         from .test.test_agents import test_agents
         test_agents(self)
@@ -341,20 +316,19 @@ class Module(MgrModule):
         self.status = {'status': DP_MGR_STAT_ENABLED}
 
         while True:
-            if self.get_configuration('diskprediction_config_mode').lower() == 'cloud':
-                enable_cloud = True
+            mode = self.get_option('device_failure_prediction_mode')
+            if mode == 'cloud':
+                if not self._activated_cloud:
+                    self.start_cloud_disk_prediction()
             else:
-                enable_cloud = False
-            # Enable cloud mode prediction process
-            if enable_cloud and not self._activated_cloud:
-                if self._activated_local:
-                    self.stop_disk_prediction()
-                self.start_cloud_disk_prediction()
-            # Enable local mode prediction process
-            elif not enable_cloud and not self._activated_local:
                 if self._activated_cloud:
                     self.stop_disk_prediction()
-                self.start_local_disk_prediction()
+            if mode == 'local':
+                if not self._activated_local:
+                    self.start_local_disk_prediction()
+            else:
+                if self._activated_local:
+                    self.stop_disk_prediction()
 
             self.shutdown_event.wait(5)
             if self.shutdown_event.is_set():