diff options
author | Zuul <zuul@review.opendev.org> | 2020-05-10 17:17:29 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-05-10 17:17:29 +0000 |
commit | d873dc84ef34f052a83608cff609b8ec6f4c5719 (patch) | |
tree | 3bb5d0744dc4d6a1e8967c9dca10ec8ef9af066e | |
parent | 01a057269a399cd5c3113a0e073d4530fe2cdec4 (diff) | |
parent | 25bb26b1859fccf132fb7ac298d7f3cb413f0f7e (diff) | |
download | zuul-d873dc84ef34f052a83608cff609b8ec6f4c5719.tar.gz |
Merge "executor: Catch error when reading cpu_times"
-rw-r--r-- | zuul/executor/server.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/zuul/executor/server.py b/zuul/executor/server.py index ac137a77f..381dc53d3 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -19,6 +19,7 @@ import json import logging import multiprocessing import os +import psutil import shutil import signal import shlex @@ -2231,17 +2232,22 @@ class AnsibleJob(object): line = line[:1024].rstrip() ansible_log.debug("Ansible output: %s" % (line,)) self.log.debug("Ansible output terminated") - cpu_times = self.proc.cpu_times() - self.log.debug("Ansible cpu times: user=%.2f, system=%.2f, " - "children_user=%.2f, " - "children_system=%.2f" % - (cpu_times.user, cpu_times.system, - cpu_times.children_user, - cpu_times.children_system)) - self.cpu_times['user'] += cpu_times.user - self.cpu_times['system'] += cpu_times.system - self.cpu_times['children_user'] += cpu_times.children_user - self.cpu_times['children_system'] += cpu_times.children_system + try: + cpu_times = self.proc.cpu_times() + self.log.debug("Ansible cpu times: user=%.2f, system=%.2f, " + "children_user=%.2f, " + "children_system=%.2f" % + (cpu_times.user, cpu_times.system, + cpu_times.children_user, + cpu_times.children_system)) + self.cpu_times['user'] += cpu_times.user + self.cpu_times['system'] += cpu_times.system + self.cpu_times['children_user'] += cpu_times.children_user + self.cpu_times['children_system'] += cpu_times.children_system + except psutil.NoSuchProcess: + self.log.warn("Cannot get cpu_times for process %d. Is your" + "/proc mounted with hidepid=2" + " on an old linux kernel?", self.proc.pid) ret = self.proc.wait() self.log.debug("Ansible exit code: %s" % (ret,)) finally: |