Merge "Restrict ceph mon hook execution"
This commit is contained in:
@@ -304,34 +304,44 @@ class RemoveKubernetesConfigSymlinkHook(BaseHook):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
# TODO(heitormatsui): delete in the future, not needed for stx-10 -> <future-releases>
|
||||||
class RemoveCephMonHook(BaseHook):
|
class RemoveCephMonHook(BaseHook):
|
||||||
"""
|
"""
|
||||||
Remove additional ceph-mon added for each controller
|
Remove additional ceph-mon added for each controller
|
||||||
"""
|
"""
|
||||||
PMON_FILE = "/etc/pmon.d/ceph-fixed-mon.conf"
|
PMON_FILE = "/etc/pmon.d/ceph-fixed-mon.conf"
|
||||||
|
|
||||||
|
def __init__(self, attrs):
|
||||||
|
super().__init__(attrs)
|
||||||
|
self._major_release = None
|
||||||
|
if "major_release" in attrs:
|
||||||
|
self._major_release = attrs.get("major_release")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
system_type = utils.get_platform_conf("system_type")
|
# (DX only) on 22.12 there is 1 mon, on 24.09 there are 3
|
||||||
system_mode = utils.get_platform_conf("system_mode")
|
# so only in 24.09 -> 22.12 rollback this hook is needed
|
||||||
nodetype = utils.get_platform_conf("nodetype")
|
if self._major_release == "22.12":
|
||||||
# additional monitors were added only for AIO-DX
|
system_type = utils.get_platform_conf("system_type")
|
||||||
if (system_type == constants.SYSTEM_TYPE_ALL_IN_ONE and
|
system_mode = utils.get_platform_conf("system_mode")
|
||||||
system_mode != constants.SYSTEM_MODE_SIMPLEX and
|
nodetype = utils.get_platform_conf("nodetype")
|
||||||
nodetype == constants.CONTROLLER):
|
# additional monitors were added only for AIO-DX
|
||||||
cmd_remove_mon_controller_0 = ["timeout", "30", "ceph", "mon", "rm", "controller-0"]
|
if (system_type == constants.SYSTEM_TYPE_ALL_IN_ONE and
|
||||||
cmd_remove_mon_controller_1 = ["timeout", "30", "ceph", "mon", "rm", "controller-1"]
|
system_mode != constants.SYSTEM_MODE_SIMPLEX and
|
||||||
try:
|
nodetype == constants.CONTROLLER):
|
||||||
subprocess.check_call(cmd_remove_mon_controller_0)
|
cmd_remove_mon_controller_0 = ["timeout", "30", "ceph", "mon", "rm", "controller-0"]
|
||||||
subprocess.check_call(cmd_remove_mon_controller_1)
|
cmd_remove_mon_controller_1 = ["timeout", "30", "ceph", "mon", "rm", "controller-1"]
|
||||||
LOG.info("Removed mon.controller-0 and mon.controller-1 from ceph cluster.")
|
try:
|
||||||
except subprocess.CalledProcessError as e:
|
subprocess.check_call(cmd_remove_mon_controller_0)
|
||||||
LOG.exception("Failure removing mon.controller-0 and mon.controller-1 from ceph cluster: %s" % str(e))
|
subprocess.check_call(cmd_remove_mon_controller_1)
|
||||||
raise
|
LOG.info("Removed mon.controller-0 and mon.controller-1 from ceph cluster.")
|
||||||
try:
|
except subprocess.CalledProcessError as e:
|
||||||
os.unlink(self.PMON_FILE)
|
LOG.exception("Failure removing mon.controller-0 and mon.controller-1 from ceph cluster: %s" % str(e))
|
||||||
LOG.info("Removed %s from pmon." % self.PMON_FILE)
|
raise
|
||||||
except FileNotFoundError:
|
try:
|
||||||
pass # ignore if link doesn't exist
|
os.unlink(self.PMON_FILE)
|
||||||
|
LOG.info("Removed %s from pmon." % self.PMON_FILE)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass # ignore if link doesn't exist
|
||||||
|
|
||||||
|
|
||||||
class RestartKubeApiServer(BaseHook):
|
class RestartKubeApiServer(BaseHook):
|
||||||
|
Reference in New Issue
Block a user