From ab0e5ae928d4fc15cf812957541c02770d13ab26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Wed, 15 Jul 2020 15:14:51 +0200 Subject: [PATCH] mgr/diskprediction_local: Fix array size error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The disk predictor assumes that it has at least 6 days worth of data to work with, and the code ensures that `health_data` contains at least 6 elements. However, it then gets fitlered down into a `predict_datas` array that can contain less than 6 elements in some cases. This commit ensures that `predict_datas` contains 6 elements or more before passing it on to the disk predictor. Fixes: https://tracker.ceph.com/issues/46549 Signed-off-by: Benoît Knecht --- src/pybind/mgr/diskprediction_local/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/mgr/diskprediction_local/module.py b/src/pybind/mgr/diskprediction_local/module.py index 61f3cc1f6dc..948c59bd7ed 100644 --- a/src/pybind/mgr/diskprediction_local/module.py +++ b/src/pybind/mgr/diskprediction_local/module.py @@ -218,7 +218,7 @@ class Module(MgrModule): else: self.log.error('unable to predict device due to health data records less than 6 days') - if predict_datas: + if len(predict_datas) >= 6: predicted_result = obj_predictor.predict(predict_datas) return predicted_result -- 2.47.3