Skip to content

Commit

Permalink
[OSMount] Add waits/retry during Ubuntu minion prep stage.
Browse files Browse the repository at this point in the history
Add wait/retry to the pre-setup stage of the Ubuntu OSMorphing
minions for installing packages required by the OSMount process.

Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
  • Loading branch information
aznashwan committed Apr 3, 2024
1 parent 7296019 commit 81674e8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions coriolis/osmorphing/osmount/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,24 @@ def check_os(self):

def setup(self):
super(UbuntuOSMountTools, self).setup()
self._exec_cmd("sudo -E apt-get update -y")
self._exec_cmd("sudo -E apt-get install lvm2 psmisc -y")

# NOTE(aznashwan): it's possible that if the Ubuntu minion has
# unattended automatic upgrades enabled, the package list
# locks (/var/lib/apt/lists/lock*) may be held because
# another package list refresh is happening.
# Apart from relying on possibly not-yet-installed tools like `fuser`,
# or checking every /proc/*/fd ourselves, we simply retry it:
retry_ssh_cmd = utils.retry_on_error(
max_attempts=10, sleep_seconds=30)(self._exec_cmd)
retry_ssh_cmd("sudo -E apt-get update -y")

# NOTE(aznashwan): in case an unattended upgrade is already happening
# and is at the package installation stage (in which case the
# /var/lib/dpkg/* locks will be held), we pass a 10-minute timeout:
self._exec_cmd(
"sudo -E apt-get -o DPkg::Lock::Timeout=600 "
"install lvm2 psmisc -y")

self._exec_cmd("sudo modprobe dm-mod")

def _allow_ssh_env_vars(self):
Expand Down

0 comments on commit 81674e8

Please sign in to comment.