From 47019b77b23c72cd2e71098c01c4d86b06d1de8c Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 19 Mar 2014 13:38:37 -0400 Subject: change to unmount then check to address possible race --- cloudinit/sources/DataSourceAzure.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cloudinit') 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: -- cgit v1.2.3