Add reboot_node method to OcpNode class
With this patch, podified topologies support rebooting an OCP node. Change-Id: I9fd06047e24e9aca5ad479170a8daf0817f97894
This commit is contained in:
@@ -557,3 +557,18 @@ def check_or_start_tobiko_http_ping_command(
|
||||
pod_name = _get_http_ping_pod_name(server_ip)
|
||||
return check_or_start_tobiko_command(
|
||||
cmd_args, pod_name, _check_http_ping_results_from_pod)
|
||||
|
||||
|
||||
def get_ocp_node_uptime(node_name: str):
|
||||
# timeout is needed to avoid that the `oc debug` command gets stuck forever
|
||||
output = sh.execute(f"timeout 10 oc debug node/{node_name} -- "
|
||||
"chroot /host cat /proc/uptime").stdout
|
||||
uptime_line = output.splitlines()[0]
|
||||
uptime_string = uptime_line.split()[0]
|
||||
return float(uptime_string)
|
||||
|
||||
|
||||
def reboot_ocp_node(node_name: str):
|
||||
LOG.debug(f"Rebooting OCP node {node_name}...")
|
||||
sh.execute(f"oc debug node/{node_name} -- chroot /host reboot")
|
||||
LOG.debug(f"Reboot command sent to OCP node {node_name}.")
|
||||
|
@@ -132,8 +132,8 @@ class PodifiedTopology(rhosp.RhospTopology):
|
||||
def create_node(self, name, ssh_client, **kwargs):
|
||||
node_type = kwargs.pop('node_type')
|
||||
if node_type == OCP_WORKER:
|
||||
return OcpWorkerNode(topology=self, name=name, ssh_client=None,
|
||||
**kwargs)
|
||||
return OcpNode(topology=self, name=name, ssh_client=None,
|
||||
**kwargs)
|
||||
else:
|
||||
return EdpmNode(topology=self, name=name, ssh_client=ssh_client,
|
||||
**kwargs)
|
||||
@@ -258,8 +258,25 @@ class EdpmNode(rhosp.RhospNode):
|
||||
LOG.debug(f"EDPM node {self.name} power is off.")
|
||||
|
||||
|
||||
class OcpWorkerNode(rhosp.RhospNode):
|
||||
pass
|
||||
class OcpNode(rhosp.RhospNode):
|
||||
def reboot_node(self, reactivate_servers=True):
|
||||
start_time = tobiko.time()
|
||||
_openshift.reboot_ocp_node(self.name)
|
||||
for _ in tobiko.retry(timeout=600, interval=10):
|
||||
try:
|
||||
uptime = _openshift.get_ocp_node_uptime(self.name)
|
||||
except Exception:
|
||||
LOG.warning(f"Unable to get uptime from node {self.name}")
|
||||
else:
|
||||
elapsed_time = tobiko.time() - start_time
|
||||
if uptime < elapsed_time:
|
||||
LOG.debug(f"OCP node {self.name} rebooted in "
|
||||
f"{elapsed_time} seconds.")
|
||||
break
|
||||
else:
|
||||
LOG.debug(f"OCP node {self.name} still not rebooted "
|
||||
f"{elapsed_time} seconds after reboot operation "
|
||||
f"(uptime={uptime})")
|
||||
|
||||
|
||||
def setup_podified_topology():
|
||||
|
Reference in New Issue
Block a user