Skip to content

Commit

Permalink
Merge pull request #229 from canonical/revert-reboot-before-provision
Browse files Browse the repository at this point in the history
Revert patches to reboot the control host before provisioning
  • Loading branch information
plars authored Mar 25, 2024
2 parents ae5b9fb + 236b184 commit 13bfec0
Showing 1 changed file with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,6 @@ def _run_control(self, cmd, timeout=60):
raise ProvisioningError(e.output)
return output

def check_control_alive(self):
"""Check if the control host is alive"""
try:
self._run_control("true")
except (ProvisioningError, subprocess.SubprocessError):
raise ProvisioningError(
"Control host is not responding, provisioning can't proceed!"
)

def reboot_control_host(self):
"""
Reboot the control host
Sometimes the control host can end up in an unstable condition which
isn't easy to detect until it's too late. Since nothing else should
be using the control host, reboot it before provisioning to ensure
it's in a known good state.
"""
self.check_control_alive()
logger.info("Rebooting control host")
# Use shutdown instead of reboot to avoid ssh disconnecting too quickly
self._run_control("sudo shutdown -r +1")
time.sleep(120)
# It should be up after 120s, but wait up to 5min if necessary
for _ in range(24):
try:
self.check_control_alive()
break
except ProvisioningError:
logger.info("Waiting for control host to become active...")
time.sleep(10)
# One final check to ensure the control host is alive, or fail
self.check_control_alive()

def _copy_to_control(self, local_file, remote_file):
"""
Copy a file to the control host over ssh
Expand Down Expand Up @@ -148,9 +114,6 @@ def _copy_to_control(self, local_file, remote_file):
return output

def provision(self):
# If this is not a zapper, reboot before provisioning
if "zapper" not in self.config.get("control_switch_local_cmd", ""):
self.reboot_control_host()
try:
url = self.job_data["provision_data"]["url"]
except KeyError:
Expand Down

0 comments on commit 13bfec0

Please sign in to comment.