From c2f56b12f48e0f23b3715fe06dbff97416cd66e3 Mon Sep 17 00:00:00 2001 From: Arata Notsu Date: Sun, 26 Aug 2012 02:47:53 +0900 Subject: Correct utils.execute() to check 0 in check_exit_code If a process exits with returncode 0, the function always returns without raising a exception, regardless of whether its check_exit_code includes 0 or not. This patch fixes it; if check_exit_code does not includes 0 and a process exits with 0, ProcessExecutionError is raised. (No change required to caller-side since no one misses 0 in check_exit_code) Change-Id: I824a9bc5e42038e27df6757cd47c06073681c342 --- nova/utils.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nova/utils.py b/nova/utils.py index 6f199e659..479ddaf46 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -188,15 +188,14 @@ def execute(*cmd, **kwargs): result = obj.communicate() obj.stdin.close() # pylint: disable=E1101 _returncode = obj.returncode # pylint: disable=E1101 - if _returncode: - LOG.debug(_('Result was %s') % _returncode) - if not ignore_exit_code and _returncode not in check_exit_code: - (stdout, stderr) = result - raise exception.ProcessExecutionError( - exit_code=_returncode, - stdout=stdout, - stderr=stderr, - cmd=' '.join(cmd)) + LOG.debug(_('Result was %s') % _returncode) + if not ignore_exit_code and _returncode not in check_exit_code: + (stdout, stderr) = result + raise exception.ProcessExecutionError( + exit_code=_returncode, + stdout=stdout, + stderr=stderr, + cmd=' '.join(cmd)) return result except exception.ProcessExecutionError: if not attempts: -- cgit