Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(disk_setup) add timeout #4673

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "0"))
missing = util.wait_for_files(
[disk], maxwait=tmout, naplen=0.1
)
if len(missing) > 0:
LOG.warning("Timeout expired waiting for %s", disk)
try:
LOG.debug("Creating new partition table/disk")
util.log_time(
Expand Down
5 changes: 5 additions & 0 deletions cloudinit/config/schemas/schema-cloud-config-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,11 @@
"type": "boolean",
"default": false,
"description": "Controls whether this module tries to be safe about writing partition tables or not. If ``overwrite: false`` is set, the device will be checked for a partition table and for a file system and if either is found, the operation will be skipped. If ``overwrite: true`` is set, no checks will be performed. Using ``overwrite: true`` is **dangerous** and can lead to data loss, so double check that the correct device has been specified if using this option. Default: ``false``"
},
"timeout": {
"type": "integer",
"default": 0,
"description": "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."
}
}
}
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
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ einsibjarni
emmanuelthome
eslerm
esposem
flokli
frantisekz
GabrielNagy
garzdin
Expand Down
Loading