aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsir...@apache.org
Subject aurora git commit: Do not split the shell command string passed into shell health check script
Date Tue, 15 Mar 2016 20:54:45 GMT
Repository: aurora
Updated Branches:
  refs/heads/master cbb206c51 -> 653758131


Do not split the shell command string passed into shell health check script

Fixing bug where you could not pass in shell command into health checker with environment
variables. When environment variable assignement was passed in, only that part would get executed
and 0 would always get returned.

Bugs closed: AURORA-1633

Reviewed at https://reviews.apache.org/r/44827/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/65375813
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/65375813
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/65375813

Branch: refs/heads/master
Commit: 653758131a9ab8ebce2bcacf2ace6a838770419b
Parents: cbb206c
Author: Dmitriy Shirchenko <caldima@gmail.com>
Authored: Tue Mar 15 14:55:38 2016 -0600
Committer: John Sirois <john.sirois@gmail.com>
Committed: Tue Mar 15 14:55:38 2016 -0600

----------------------------------------------------------------------
 src/main/python/apache/aurora/common/health_check/shell.py   | 4 +---
 .../python/apache/aurora/common/health_check/test_shell.py   | 8 ++++----
 2 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/65375813/src/main/python/apache/aurora/common/health_check/shell.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/common/health_check/shell.py b/src/main/python/apache/aurora/common/health_check/shell.py
index bf63d93..6cb7dfc 100644
--- a/src/main/python/apache/aurora/common/health_check/shell.py
+++ b/src/main/python/apache/aurora/common/health_check/shell.py
@@ -13,7 +13,6 @@
 #
 
 import os
-import shlex
 import sys
 
 # Recommended pattern for Python 2 and 3 support from https://github.com/google/python-subprocess32
@@ -45,9 +44,8 @@ class ShellHealthCheck(object):
     :return: A tuple of (bool, str)
     :rtype tuple:
     """
-    cmd = shlex.split(self.cmd)
     try:
-      subprocess.check_call(cmd, timeout=self.timeout_secs, shell=True)
+      subprocess.check_call(self.cmd, timeout=self.timeout_secs, shell=True)
       return True, None
     except subprocess.CalledProcessError as reason:
       # The command didn't return a 0 so provide reason for failure.

http://git-wip-us.apache.org/repos/asf/aurora/blob/65375813/src/test/python/apache/aurora/common/health_check/test_shell.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/common/health_check/test_shell.py b/src/test/python/apache/aurora/common/health_check/test_shell.py
index 8d3a3e4..7026af8 100644
--- a/src/test/python/apache/aurora/common/health_check/test_shell.py
+++ b/src/test/python/apache/aurora/common/health_check/test_shell.py
@@ -40,7 +40,7 @@ class TestHealthChecker(unittest.TestCase):
     self.assertTrue(success)
     self.assertIsNone(msg)
     mock_sub.assert_called_once_with(
-      ['success', 'cmd'],
+      'success cmd',
       timeout=30,
       shell=True,
     )
@@ -54,7 +54,7 @@ class TestHealthChecker(unittest.TestCase):
     shell = ShellHealthCheck(cmd, timeout_secs=timeout)
     success, msg = shell()
     mock_sub.assert_called_once_with(
-      ['cmd', 'to', 'fail'],
+      'cmd to fail',
       timeout=30,
       shell=True,
     )
@@ -70,7 +70,7 @@ class TestHealthChecker(unittest.TestCase):
     shell = ShellHealthCheck(cmd, timeout_secs=timeout)
     success, msg = shell()
     mock_sub.assert_called_once_with(
-      ['cmd', 'to', 'not', 'exist'],
+      'cmd to not exist',
       timeout=30,
       shell=True,
     )
@@ -87,7 +87,7 @@ class TestHealthChecker(unittest.TestCase):
     shell = ShellHealthCheck(cmd, timeout_secs=timeout)
     success, msg = shell()
     mock_sub.assert_called_once_with(
-      ['defensive', 'cmd'],
+      'defensive cmd',
       timeout=10,
       shell=True,
     )


Mime
View raw message