Skip to content

Commit

Permalink
feat(disk_setup) add timeout
Browse files Browse the repository at this point in the history
In a cloud environment, sometimes disks will attach while cloud-init is
running and get missed. This adds a configurable timeout to wait for
those disks.

Signed-off-by: Florian Klink <flokli@flokli.de>
  • Loading branch information
nibalizer authored and flokli committed Dec 7, 2023
1 parent dac62ec commit 890dd47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cloudinit/config/cc_disk_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def alias_to_device(cand):
LOG.warning("Invalid disk definition for %s", disk)
continue

if definition.get("timeout"):
tmout = int(definition.get("timeout"))
need = util.wait_for_files([disk],
maxwait=tmout,
naplen=0.1)
if len(need) > 0:
log.warning("Timeout expired waiting for %s" % disk)
try:
LOG.debug("Creating new partition table/disk")
util.log_time(
Expand Down
6 changes: 6 additions & 0 deletions doc/examples/cloud-config-disk-setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ disk_setup:
# table_type: 'mbr'
# layout: <LAYOUT|BOOL>
# overwrite: <BOOL>
# timeout: <INT>
#
# Where:
# <DEVICE>: The name of the device. 'ephemeralX' and 'swap' are special
Expand Down Expand Up @@ -160,6 +161,11 @@ disk_setup:
# done blindly. USE with caution, you can do things you
# really, really don't want to do.
#
# timeout=<INT>: Seconds to wait for a disk to appear. If omitted, no wait
# is performed. This is useful if a cloud provider has late or
# inconsistent disk attachments and you need a delay.
#
#
#
# fs_setup: Setup the filesystem
# ------------------------------
Expand Down

0 comments on commit 890dd47

Please sign in to comment.