summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/sources/DataSourceAzure.py13
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: