Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@

https://docs.ceph.com/en/latest/rados/operations/placement-groups/

* MGR: The pg_autoscaler can now be turned `on` and `off` globally
with the `noautoscale` flag. By default this flag is unset and
the default pg_autoscale mode remains the same.
For more details, see:

https://docs.ceph.com/en/latest/rados/operations/placement-groups/

* The ``ceph pg dump`` command now prints two additional columns:
`LAST_SCRUB_DURATION` shows the duration (in seconds) of the last completed scrub;
`SCRUB_SCHEDULING` conveys whether a PG is scheduled to be scrubbed at a specified
Expand Down
14 changes: 14 additions & 0 deletions doc/rados/operations/placement-groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ set on any pools that are subsequently created::

ceph config set global osd_pool_default_pg_autoscale_mode <mode>

You can disable or enable the autoscaler for all pools with
the ``noautoscale`` flag. By default this flag is set to be ``off``,
but you can turn it ``on`` by using the command::

ceph osd pool set noautoscale

You can turn it ``off`` using the command::

ceph osd pool unset noautoscale

To ``get`` the value of the flag use the command::

ceph osd pool get noautoscale

Viewing PG scaling recommendations
----------------------------------

Expand Down
39 changes: 39 additions & 0 deletions qa/suites/rados/singleton/all/test-noautoscale-flag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
roles:
- - mon.a
- mgr.x
- osd.0
- osd.1
- osd.2
- osd.3
- client.0
openstack:
- volumes: # attached to each instance
count: 4
size: 10 # GB
overrides:
ceph:
create_rbd_pool: false
pre-mgr-commands:
- sudo ceph config set mgr mgr_pool false --force
conf:
mon:
osd pool default pg autoscale mode: on
log-ignorelist:
- overall HEALTH_
- \(OSDMAP_FLAGS\)
- \(OSD_
- \(PG_
- \(POOL_
- \(CACHE_POOL_
- \(OBJECT_
- \(SLOW_OPS\)
- \(REQUEST_SLOW\)
- \(TOO_FEW_PGS\)
- slow request
tasks:
- install:
- ceph:
- workunit:
clients:
all:
- mon/test_noautoscale_flag.sh
83 changes: 83 additions & 0 deletions qa/workunits/mon/test_noautoscale_flag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash -ex

unset CEPH_CLI_TEST_DUP_COMMAND

NUM_POOLS=$(ceph osd pool ls | wc -l)

if [ "$NUM_POOLS" -gt 0 ]; then
echo "test requires no preexisting pools"
exit 1
fi

ceph osd pool set noautoscale

ceph osd pool create pool_a

echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')

NUM_POOLS=$[NUM_POOLS+1]

sleep 2

# Count the number of Pools with AUTOSCALE `off`

RESULT1=$(ceph osd pool autoscale-status | grep -oe 'off' | wc -l)

# number of Pools with AUTOSCALE `off` should equal to 2

test "$RESULT1" -eq "$NUM_POOLS"

ceph osd pool unset noautoscale

echo $(ceph osd pool get noautoscale)


ceph osd pool create pool_b

echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')

echo 'pool_b autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_b | grep -o -m 1 'on\|off')


NUM_POOLS=$[NUM_POOLS+1]

sleep 2

# Count the number of Pools with AUTOSCALE `on`

RESULT2=$(ceph osd pool autoscale-status | grep -oe 'on' | wc -l)

# number of Pools with AUTOSCALE `on` should equal to 3

test "$RESULT2" -eq "$NUM_POOLS"

ceph osd pool set noautoscale

ceph osd pool create pool_c

echo 'pool_a autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_a | grep -o -m 1 'on\|off')

echo 'pool_b autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_b | grep -o -m 1 'on\|off')

echo 'pool_c autoscale_mode:' $(ceph osd pool autoscale-status | grep pool_c | grep -o -m 1 'on\|off')


NUM_POOLS=$[NUM_POOLS+1]

sleep 2

# Count the number of Pools with AUTOSCALE `off`

RESULT3=$(ceph osd pool autoscale-status | grep -oe 'off' | wc -l)

# number of Pools with AUTOSCALE `off` should equal to 4

test "$RESULT3" -eq "$NUM_POOLS"

ceph osd pool rm pool_a pool_a --yes-i-really-really-mean-it

ceph osd pool rm pool_b pool_b --yes-i-really-really-mean-it

ceph osd pool rm pool_c pool_c --yes-i-really-really-mean-it

echo OK
84 changes: 84 additions & 0 deletions src/pybind/mgr/pg_autoscaler/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ class PgAutoscaler(MgrModule):
'`PG_NUM` before being accepted. Cannot be less than 1.0'),
default=3.0,
min=1.0),
Option(
name='noautoscale',
type='bool',
desc='global autoscale flag',
long_desc=('Option to turn on/off the autoscaler for all pools'),
default=False),
]

def __init__(self, *args: Any, **kwargs: Any) -> None:
Expand All @@ -149,6 +155,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.sleep_interval = 60
self.mon_target_pg_per_osd = 0
self.threshold = 3.0
self.noautoscale = False

def config_notify(self) -> None:
for opt in self.NATIVE_OPTIONS:
Expand Down Expand Up @@ -247,6 +254,79 @@ def set_scaling_threshold(self, num: float) -> Tuple[int, str, str]:
self.set_module_option("threshold", num)
return 0, "threshold updated", ""

def complete_all_progress_events(self) -> None:
for pool_id in list(self._event):
ev = self._event[pool_id]
self.remote('progress', 'complete', ev.ev_id)
del self._event[pool_id]

def set_autoscale_mode_all_pools(self, status: str) -> None:
osdmap = self.get_osdmap()
pools = osdmap.get_pools_by_name()
for pool_name, _ in pools.items():
self.mon_command({
'prefix': 'osd pool set',
'pool': pool_name,
'var': 'pg_autoscale_mode',
'val': status
})
@CLIWriteCommand("osd pool get noautoscale")
def get_noautoscale(self) -> Tuple[int, str, str]:
"""
Get the noautoscale flag to see if all pools
are setting the autoscaler on or off as well
as newly created pools in the future.
"""

if self.noautoscale == None:
raise TypeError("noautoscale cannot be None")
elif self.noautoscale:
return 0, "", "noautoscale is on"
else:
return 0, "", "noautoscale is off"

@CLIWriteCommand("osd pool unset noautoscale")
def unset_noautoscale(self) -> Tuple[int, str, str]:
"""
Unset the noautoscale flag so all pools will
have autoscale enabled (including newly created
pools in the future).
"""
if not self.noautoscale:
return 0, "", "noautoscale is already unset!"
else:
self.set_module_option("noautoscale", False)
self.mon_command({
'prefix': 'config set',
'who': 'global',
'name': 'osd_pool_default_pg_autoscale_mode',
'value': 'on'
})
self.set_autoscale_mode_all_pools("on")
return 0, "", "noautoscale is unset, all pools now have autoscale on"

@CLIWriteCommand("osd pool set noautoscale")
def set_noautoscale(self) -> Tuple[int, str, str]:
"""
set the noautoscale for all pools (including
newly created pools in the future)
and complete all on-going progress events
regarding PG-autoscaling.
"""
if self.noautoscale:
return 0, "", "noautoscale is already set!"
else:
self.set_module_option("noautoscale", True)
self.mon_command({
'prefix': 'config set',
'who': 'global',
'name': 'osd_pool_default_pg_autoscale_mode',
'value': 'off'
})
self.set_autoscale_mode_all_pools("off")
self.complete_all_progress_events()
return 0, "", "noautoscale is set, all pools now have autoscale off"

def serve(self) -> None:
self.config_notify()
while not self._shutdown.is_set():
Expand Down Expand Up @@ -583,6 +663,8 @@ def _get_pool_status(
return (ret, root_map)

def _update_progress_events(self) -> None:
if self.noautoscale:
return
osdmap = self.get_osdmap()
pools = osdmap.get_pools()
for pool_id in list(self._event):
Expand All @@ -596,6 +678,8 @@ def _update_progress_events(self) -> None:
ev.update(self, (ev.pg_num - pool_data['pg_num']) / (ev.pg_num - ev.pg_num_target))

def _maybe_adjust(self) -> None:
if self.noautoscale:
return
self.log.info('_maybe_adjust')
osdmap = self.get_osdmap()
if osdmap.get_require_osd_release() < 'nautilus':
Expand Down