summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_power_state_change.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-11-13 14:02:14 -0500
committerScott Moser <smoser@ubuntu.com>2012-11-13 14:02:14 -0500
commit8239df4493d81db1d245eaa51fdfe5458e2d1e4f (patch)
tree93d1af99d6568d954e4fa9def23c91c0b4800954 /cloudinit/config/cc_power_state_change.py
parentefd02682c7cfb054490308443f7f9facf83363b5 (diff)
downloadvyos-cloud-init-8239df4493d81db1d245eaa51fdfe5458e2d1e4f.tar.gz
vyos-cloud-init-8239df4493d81db1d245eaa51fdfe5458e2d1e4f.zip
add sleep, allow errno '3' (ESRCH) on the open of /proc/pid/cmdline
The sleep is added here simply to not completely spin cpu on waiting for the parent pid to die. the allowing of errno 3 is because I was getting this. I dont have a perfect explanation, but I suspect that the 'open' was actually getting this back from the /proc filesystem after the pid had died. Possibly in the window between when the 'open' was done and the 'read()' was done.
Diffstat (limited to 'cloudinit/config/cc_power_state_change.py')
-rw-r--r--cloudinit/config/cc_power_state_change.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/cloudinit/config/cc_power_state_change.py b/cloudinit/config/cc_power_state_change.py
index 22f1aade..02434322 100644
--- a/cloudinit/config/cc_power_state_change.py
+++ b/cloudinit/config/cc_power_state_change.py
@@ -121,6 +121,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args):
log.warn(msg)
doexit(EXIT_FAIL)
+ known_errnos = (errno.ENOENT, errno.ESRCH)
+
while True:
if time.time() > end_time:
msg = "timeout reached before %s ended" % pid
@@ -135,8 +137,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args):
break
except IOError as ioerr:
- if ioerr.errno == errno.ENOENT:
- msg = "pidfile '%s' gone" % cmdline_f
+ if ioerr.errno in known_errnos:
+ msg = "pidfile '%s' gone [%d]" % (cmdline_f, ioerr.errno)
else:
fatal("IOError during wait: %s" % ioerr)
break
@@ -144,6 +146,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args):
except Exception as e:
fatal("Unexpected Exception: %s" % e)
+ time.sleep(.25)
+
if not msg:
fatal("Unexpected error in run_after_pid_gone")