From e016e7c7837c70f5fce0c3b3d9bd944a8d43f9f0 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 13 Nov 2012 15:27:00 -0500 Subject: 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. --- cloudinit/helpers.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'cloudinit/helpers.py') 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): -- cgit v1.2.3