summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-11-13 15:27:00 -0500
committerScott Moser <smoser@ubuntu.com>2012-11-13 15:27:00 -0500
commite016e7c7837c70f5fce0c3b3d9bd944a8d43f9f0 (patch)
tree44fbdf43483489f20ffba7cea188f7c435caac2f /cloudinit
parentbf3c3bb2f5f443aa44a0ff85037861b73c3aad65 (diff)
downloadvyos-cloud-init-e016e7c7837c70f5fce0c3b3d9bd944a8d43f9f0.tar.gz
vyos-cloud-init-e016e7c7837c70f5fce0c3b3d9bd944a8d43f9f0.zip
check for a marker file by the normal name also
This check is a waste of a stat any time after the migrator module had run. As it would take care of moving markers. However, if the user runs: sudo cloud-init modules --mode final after an upgrade, they'd otherwise run any module that had a '-' in its name again. To avoid that, we just return true in that case, and inform the user how to run the migrator themselves.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/helpers.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/cloudinit/helpers.py b/cloudinit/helpers.py
index 794f00ec..2077401c 100644
--- a/cloudinit/helpers.py
+++ b/cloudinit/helpers.py
@@ -125,12 +125,23 @@ class FileSemaphores(object):
def has_run(self, name, freq):
if not freq or freq == PER_ALWAYS:
return False
- name = canon_sem_name(name)
- sem_file = self._get_path(name, freq)
+
+ cname = canon_sem_name(name)
+ sem_file = self._get_path(cname, freq)
# This isn't really a good atomic check
# but it suffices for where and when cloudinit runs
if os.path.exists(sem_file):
return True
+
+ # this case could happen if the migrator module hadn't run yet
+ # but the item had run before we did canon_sem_name.
+ if cname != name and os.path.exists(self._get_path(name, freq)):
+ LOG.warn("%s has run without canonicalized name [%s].\n"
+ "likely the migrator has not yet run. It will run next boot.\n"
+ "run manually with: cloud-init single --name=migrator"
+ % (name, cname))
+ return True
+
return False
def _get_path(self, name, freq):