Skip to content

Commit

Permalink
feat(slurmd): account for Juju auto-upgrading base image
Browse files Browse the repository at this point in the history
Adds reboot check as first step in install hook in case of a
pending kernel update.
  • Loading branch information
dsloanm committed Jan 7, 2025
1 parent a03b6c6 commit cfaa60b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions charms/slurmd/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def __init__(self, *args, **kwargs):

def _on_install(self, event: InstallEvent) -> None:
"""Perform installation operations for slurmd."""
# Account for case where base image has been auto-upgraded by Juju and a reboot is pending
# before charm code runs. Reboot "now", before the current hook completes, and restart the
# hook after reboot. Prevents issues such as drivers/kernel modules being installed for a
# running kernel pending replacement by a newer version on reboot.
self._reboot_if_required(now=True)

self.unit.status = WaitingStatus("installing slurmd")

try:
Expand Down Expand Up @@ -325,11 +331,11 @@ def _check_status(self) -> bool:

return True

def _reboot_if_required(self) -> None:
def _reboot_if_required(self, now: bool = False) -> None:
"""Perform a reboot of the unit if required, e.g. following a driver installation."""
if Path("/var/run/reboot-required").exists():
logger.info("unit rebooting")
self.unit.reboot()
self.unit.reboot(now)

@staticmethod
def _ranges_and_strides(nums) -> str:
Expand Down

0 comments on commit cfaa60b

Please sign in to comment.