Explorar o código

AMBARI-5186. On EC2, AMI for RHEL 5.7 does not start postgres on setup (aonishuk)

Andrew Onischuk %!s(int64=11) %!d(string=hai) anos
pai
achega
fcccee374c

+ 15 - 10
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:

+ 4 - 0
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()