From 772d7c1d3c1adf49821670da0f6cdb06e293dc0d Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Sat, 1 Feb 2020 14:59:13 -0500 Subject: [PATCH] mgr/pg_autoscaler: add warning when target bytes and ratio are both set Signed-off-by: Josh Durgin --- doc/rados/operations/health-checks.rst | 15 +++++++++++++++ qa/workunits/mon/pg_autoscaler.sh | 5 +++++ src/pybind/mgr/pg_autoscaler/module.py | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/doc/rados/operations/health-checks.rst b/doc/rados/operations/health-checks.rst index 85eeea9afc0..bd71a2ee937 100644 --- a/doc/rados/operations/health-checks.rst +++ b/doc/rados/operations/health-checks.rst @@ -848,6 +848,21 @@ the pool is too large and should be reduced or set to zero with:: For more information, see :ref:`specifying_pool_target_size`. +POOL_HAS_TARGET_SIZE_BYTES_AND_RATIO +____________________________________ + +One or more pools have both ``target_size_bytes`` and +``target_size_ratio`` set to estimate the expected size of the pool. +Only one of these properties should be non-zero. If both are set, +``target_size_ratio`` takes precedence and ``target_size_bytes`` is +ignored. + +To reset ``target_size_bytes`` to zero:: + + ceph osd pool set target_size_bytes 0 + +For more information, see :ref:`specifying_pool_target_size`. + TOO_FEW_OSDS ____________ diff --git a/qa/workunits/mon/pg_autoscaler.sh b/qa/workunits/mon/pg_autoscaler.sh index cf7bf0cc4c2..706f87d0e1b 100755 --- a/qa/workunits/mon/pg_autoscaler.sh +++ b/qa/workunits/mon/pg_autoscaler.sh @@ -68,6 +68,11 @@ ceph osd pool set a target_size_ratio 0 ceph osd pool set b target_size_ratio 0 wait_for 60 "ceph health detail | grep POOL_TARGET_SIZE_BYTES_OVERCOMMITTED" +ceph osd pool set a target_size_bytes 1000 +ceph osd pool set b target_size_bytes 1000 +ceph osd pool set a target_size_ratio 1 +wait_for 60 "ceph health detail | grep POOL_HAS_TARGET_SIZE_BYTES_AND_RATIO" + ceph osd pool rm a a --yes-i-really-really-mean-it ceph osd pool rm b b --yes-i-really-really-mean-it diff --git a/src/pybind/mgr/pg_autoscaler/module.py b/src/pybind/mgr/pg_autoscaler/module.py index 12b1e13ffa9..62e29464e0c 100644 --- a/src/pybind/mgr/pg_autoscaler/module.py +++ b/src/pybind/mgr/pg_autoscaler/module.py @@ -427,6 +427,7 @@ class PgAutoscaler(MgrModule): # drop them from consideration. too_few = [] too_many = [] + bytes_and_ratio = [] health_checks = {} total_bytes = dict([(r, 0) for r in iter(root_map)]) @@ -435,6 +436,9 @@ class PgAutoscaler(MgrModule): for p in ps: pool_id = str(p['pool_id']) + pool_opts = pools[p['pool_name']]['options'] + if pool_opts.get('target_size_ratio', 0) > 0 and pool_opts.get('target_size_bytes', 0) > 0: + bytes_and_ratio.append('Pool %s has target_size_bytes and target_size_ratio set' % p['pool_name']) total_bytes[p['crush_root_id']] += max( p['actual_raw_used'], p['target_bytes'] * p['raw_used_rate']) @@ -546,5 +550,12 @@ class PgAutoscaler(MgrModule): 'detail': too_much_target_bytes, } + if bytes_and_ratio: + health_checks['POOL_HAS_TARGET_SIZE_BYTES_AND_RATIO'] = { + 'severity': 'warning', + 'summary': "%d pools have both target_size_bytes and target_size_ratio set" % len(bytes_and_ratio), + 'count': len(bytes_and_ratio), + 'detail': bytes_and_ratio, + } self.set_health_checks(health_checks) -- 2.39.5