COMMAND("osd set "
"name=key,type=CephChoices,strings=full|pause|noup|nodown|"
"noout|noin|nobackfill|norebalance|norecover|noscrub|nodeep-scrub|"
- "notieragent|nosnaptrim|pglog_hardlimit "
+ "notieragent|nosnaptrim|pglog_hardlimit|noautoscale "
"name=yes_i_really_mean_it,type=CephBool,req=false",
"set <key>", "osd", "rw")
COMMAND("osd unset "
"name=key,type=CephChoices,strings=full|pause|noup|nodown|"\
"noout|noin|nobackfill|norebalance|norecover|noscrub|nodeep-scrub|"
- "notieragent|nosnaptrim",
+ "notieragent|nosnaptrim|noautoscale",
"unset <key>", "osd", "rw")
COMMAND("osd require-osd-release "\
"name=release,type=CephChoices,strings=octopus|pacific|quincy "
'`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:
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:
p['pg_num_target'],
# p['pg_num_ideal'],
final,
- p['pg_autoscale_mode'],
+ 'off' if self.has_noautoscale_flag() else p['pg_autoscale_mode'],
str(p['bulk'])
])
return 0, table.get_string(), ''
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
- })
+ def has_noautoscale_flag(self) -> bool:
+ flags = self.get_osdmap().dump().get('flags', '')
+ if 'noautoscale' in flags:
+ return True
+ else:
+ return False
+
@CLIWriteCommand("osd pool get noautoscale")
def get_noautoscale(self) -> Tuple[int, str, str]:
"""
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:
+ if self.has_noautoscale_flag():
return 0, "", "noautoscale is on"
else:
return 0, "", "noautoscale is off"
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).
+ go back to its previous mode. Newly created
+ pools in the future will autoscaler on by default.
"""
- if not self.noautoscale:
+ if not self.has_noautoscale_flag():
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"
+ self.mon_command({
+ 'prefix': 'osd unset',
+ 'key': 'noautoscale'
+ })
+ return 0, "", "noautoscale is unset, all pools now back to its previous mode"
@CLIWriteCommand("osd pool set noautoscale")
def set_noautoscale(self) -> Tuple[int, str, str]:
and complete all on-going progress events
regarding PG-autoscaling.
"""
- if self.noautoscale:
+ if self.has_noautoscale_flag():
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.mon_command({
+ 'prefix': 'osd set',
+ 'key': 'noautoscale'
+ })
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():
- self._maybe_adjust()
- self._update_progress_events()
+ if not self.has_noautoscale_flag():
+ self._maybe_adjust()
+ self._update_progress_events()
self._shutdown.wait(timeout=self.sleep_interval)
def shutdown(self) -> None:
return (ret, root_map)
def _update_progress_events(self) -> None:
- if self.noautoscale:
+ # Update progress events if necessary
+ if self.has_noautoscale_flag():
+ self.log.debug("noautoscale_flag is set.")
return
osdmap = self.get_osdmap()
pools = osdmap.get_pools()
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')
+ if self.has_noautoscale_flag():
+ self.log.debug("noautoscale_flag is set.")
+ return
osdmap = self.get_osdmap()
if osdmap.get_require_osd_release() < 'nautilus':
return