Repository: ambari Updated Branches: refs/heads/branch-1.5.0 ea38fa30b -> 73b6b830f refs/heads/trunk 1f8f6de2c -> fcccee374
AMBARI-5186. On EC2, AMI for RHEL 5.7 does not start postgres on setup (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fcccee37 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fcccee37 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fcccee37 Branch: refs/heads/trunk Commit: fcccee374cb806a135722aa99356d3a888a137f5 Parents: 1f8f6de Author: Andrew Onischuk <aonis...@hortonworks.com> Authored: Mon Mar 24 08:41:03 2014 -0700 Committer: Andrew Onischuk <aonis...@hortonworks.com> Committed: Mon Mar 24 08:41:03 2014 -0700 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 25 ++++++++++++-------- .../src/test/python/TestAmbariServer.py | 4 ++++ 2 files changed, 19 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fcccee37/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index 79eead7..6c9fcd3 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -54,6 +54,7 @@ OS = OSCheck().get_os_family() OS_UBUNTU = 'ubuntu' OS_FEDORA = 'fedora' OS_OPENSUSE = 'opensuse' +OS_SUSE = 'suse' # action commands SETUP_ACTION = "setup" @@ -1053,17 +1054,21 @@ def check_postgre_up(): stdin=subprocess.PIPE, stderr=subprocess.PIPE ) - time.sleep(20) - result = process.poll() - print_info_msg("Result of postgres start cmd: " + str(result)) - if result is None: - process.kill() - pg_status = get_postgre_status() - if pg_status == PG_STATUS_RUNNING: - print_info_msg("Postgres process is running. Returning...") - return 0 + if OS == OS_SUSE: + time.sleep(20) + result = process.poll() + print_info_msg("Result of postgres start cmd: " + str(result)) + if result is None: + process.kill() + pg_status = get_postgre_status() + else: + retcode = result else: - retcode = result + out, err = process.communicate() + retcode = process.returncode + if pg_status == PG_STATUS_RUNNING: + print_info_msg("Postgres process is running. Returning...") + return 0 except (Exception), e: pg_status = get_postgre_status() if pg_status == PG_STATUS_RUNNING: http://git-wip-us.apache.org/repos/asf/ambari/blob/fcccee37/ambari-server/src/test/python/TestAmbariServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py index 54e4077..46c3e4c 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -29,6 +29,7 @@ import stat import datetime import operator import json +import platform from pwd import getpwnam from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException @@ -2019,11 +2020,14 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV popen_mock, sleep_mock): p = MagicMock() p.poll.return_value = 0 + p.communicate.return_value = (None, None) + p.returncode = 0 popen_mock.return_value = p run_os_command_mock.return_value = (0, None, None) rcode = ambari_server.check_postgre_up() self.assertEqual(0, rcode) + ambari_server.OS = 'suse' p.poll.return_value = 4 get_postgre_status_mock.return_value = None rcode = ambari_server.check_postgre_up()