diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-03-19 13:38:37 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-03-19 13:38:37 -0400 |
commit | 47019b77b23c72cd2e71098c01c4d86b06d1de8c (patch) | |
tree | 578562861a532fdd89aea7b7c6f3702a8e2e6739 /cloudinit/sources | |
parent | 2025632daf5b202dbe6424a112d8689a1f93d9ac (diff) | |
download | vyos-cloud-init-47019b77b23c72cd2e71098c01c4d86b06d1de8c.tar.gz vyos-cloud-init-47019b77b23c72cd2e71098c01c4d86b06d1de8c.zip |
change to unmount then check to address possible race
Diffstat (limited to 'cloudinit/sources')
-rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index ffb4ff87..39b8f4f6 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -269,7 +269,18 @@ def support_new_ephemeral(cfg): if file_count >= 1: LOG.debug("fabric prepared ephemeral0.1 will be preserved") return None - elif device in util.mounted(): + else: + # if device was already mounted, then we need to unmount it + # race conditions could allow for a check-then-unmount + # to have a false positive. so just unmount and then check. + try: + util.subp(['umount', device]) + except util.ProcessExecutionError as e: + if device in util.mounts(): + LOG.warn("Failed to unmount %s, will not reformat", device) + return None + + if device in util.mounts(): try: util.subp(['umount', device]) except util.ProcessExecutionError as e: |