You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/04/28 15:06:22 UTC

git commit: AMBARI-5590. After reboot ambari-agent and server fail to start on Ubuntu (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 5c49faf56 -> d9ebe6a82


AMBARI-5590. After reboot ambari-agent and server fail to start on Ubuntu (aonishuk)


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

Branch: refs/heads/trunk
Commit: d9ebe6a82a493d0331733d61820e05744c301f03
Parents: 5c49faf
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Apr 28 16:06:14 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Apr 28 16:06:14 2014 +0300

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/ProcessHelper.py | 7 ++++---
 ambari-agent/src/main/python/ambari_agent/main.py          | 3 +++
 ambari-server/src/main/python/ambari-server.py             | 2 ++
 ambari-server/src/test/python/TestAmbariServer.py          | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d9ebe6a8/ambari-agent/src/main/python/ambari_agent/ProcessHelper.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ProcessHelper.py b/ambari-agent/src/main/python/ambari_agent/ProcessHelper.py
index 7533480..ae3345d 100644
--- a/ambari-agent/src/main/python/ambari_agent/ProcessHelper.py
+++ b/ambari-agent/src/main/python/ambari_agent/ProcessHelper.py
@@ -26,11 +26,12 @@ from shell import getTempFiles
 
 logger = logging.getLogger()
 
-
 if 'AMBARI_PID_DIR' in os.environ:
-    pidfile = os.environ['AMBARI_PID_DIR'] + "/ambari-agent.pid"
+    piddir = os.environ['AMBARI_PID_DIR']
 else:
-    pidfile = "/var/run/ambari-agent/ambari-agent.pid"
+    piddir = "/var/run/ambari-agent"
+
+pidfile = os.path.join(piddir, "ambari-agent.pid")
 
 
 def _clean():

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9ebe6a8/ambari-agent/src/main/python/ambari_agent/main.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/main.py b/ambari-agent/src/main/python/ambari_agent/main.py
index a140075..67b47b3 100644
--- a/ambari-agent/src/main/python/ambari_agent/main.py
+++ b/ambari-agent/src/main/python/ambari_agent/main.py
@@ -151,6 +151,9 @@ def daemonize():
   # Daemonize current instance of Ambari Agent
   # Currently daemonization is done via /usr/sbin/ambari-agent script (nohup)
   # and agent only dumps self pid to file
+  if not os.path.exists(ProcessHelper.piddir):
+    os.makedirs(ProcessHelper.piddir, 0755)
+  
   pid = str(os.getpid())
   file(ProcessHelper.pidfile, 'w').write(pid)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9ebe6a8/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 5adf44d..a3f5008 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -2495,6 +2495,8 @@ def start(args):
   pidfile = PID_DIR + os.sep + PID_NAME
   command_base = SERVER_START_CMD_DEBUG if (SERVER_DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD
   command = command_base.format(jdk_path, conf_dir, get_ambari_classpath(), pidfile)
+  if not os.path.exists(PID_DIR):
+    os.makedirs(PID_DIR, 0755)
   if is_root() and ambari_user != "root":
     # To inherit exported environment variables (especially AMBARI_PASSPHRASE),
     # from subprocess, we have to skip --login option of su command. That's why

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9ebe6a8/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 51d3c64..3568fd2 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -2463,6 +2463,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     self.assertEqual(None, rcode)
     self.assertTrue(setup_db_mock.called)
 
+  @patch('os.makedirs')
   @patch.object(ambari_server.utils, 'locate_file')
   @patch.object(ambari_server, 'is_server_runing')
   @patch("os.chown")
@@ -2496,7 +2497,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
                   get_ambari_properties_mock, os_environ_mock,
                   get_validated_string_input_method, os_chmod_method,
                   save_master_key_method, get_master_key_location_method,
-                  getpwnam_mock, os_chown_mock, is_server_running_mock, locate_file_mock):
+                  getpwnam_mock, os_chown_mock, is_server_running_mock, locate_file_mock,
+                  os_makedirs_mock):
      args = MagicMock()
      locate_file_mock.side_effect = lambda *args: '/bin/su' if args[0] == 'su' else '/bin/sh'
      f = MagicMock()