ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fba...@apache.org
Subject ambari git commit: AMBARI-10819 Ambari bootstrap: Premature Agent shutdown may lead to Agent stall
Date Thu, 30 Apr 2015 17:52:02 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f5c86d990 -> 2be054d18


AMBARI-10819 Ambari bootstrap: Premature Agent shutdown may lead to Agent stall

Removed the agent stop invocation. The agent restarts now only after all the bits have been
deployed.


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

Branch: refs/heads/trunk
Commit: 2be054d180fd1b7328e68f01732ed51bc67c0862
Parents: f5c86d9
Author: Florian Barca <fbarca@hortonworks.com>
Authored: Thu Apr 30 10:51:04 2015 -0700
Committer: Florian Barca <fbarca@hortonworks.com>
Committed: Thu Apr 30 10:51:35 2015 -0700

----------------------------------------------------------------------
 ambari-agent/conf/unix/ambari-agent             |  6 ++++--
 ambari-server/src/main/python/setupAgent.py     | 15 ++++++++-------
 ambari-server/src/test/python/TestSetupAgent.py |  6 +++---
 3 files changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2be054d1/ambari-agent/conf/unix/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/ambari-agent b/ambari-agent/conf/unix/ambari-agent
index b03a3a4..bc61af2 100755
--- a/ambari-agent/conf/unix/ambari-agent
+++ b/ambari-agent/conf/unix/ambari-agent
@@ -220,8 +220,10 @@ case "$1" in
         ;;
   restart)
         echo -e "Restarting $AMBARI_AGENT"
-        $0 stop
-        $0 start "$@"
+        scriptpath=$0
+        $scriptpath stop
+        shift
+        $scriptpath start "$@"
         retcode=$?
         ;;
   reset)

http://git-wip-us.apache.org/repos/asf/ambari/blob/2be054d1/ambari-server/src/main/python/setupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py
index ff2c5e9..a762d54 100755
--- a/ambari-server/src/main/python/setupAgent.py
+++ b/ambari-server/src/main/python/setupAgent.py
@@ -182,21 +182,22 @@ def runAgent(passPhrase, expected_hostname, user_run_as, verbose, ret=None):
   return {"exitstatus": agent_retcode, "log": log}
 
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
-def tryStopAgent():
+def checkVerbose():
   verbose = False
   if os.path.exists(AMBARI_AGENT_INSTALL_SYMLINK):
-    agentStopCmd = ["cmd", "/c", "ambari-agent.cmd", "stop"]
-    execOsCommand(agentStopCmd, tries=3, try_sleep=10, cwd=AMBARI_AGENT_INSTALL_SYMLINK)
+    agentStatusCmd = ["cmd", "/c", "ambari-agent.cmd", "status"]
+    ret = execOsCommand(agentStatusCmd, tries=3, try_sleep=10, cwd=AMBARI_AGENT_INSTALL_SYMLINK)
+    if ret["exitstatus"] == 0 and ret["log"][0].find("running") != -1:
+      verbose = True
   return verbose
 
 @OsFamilyFuncImpl(OsFamilyImpl.DEFAULT)
-def tryStopAgent():
+def checkVerbose():
   verbose = False
   cmds = ["bash", "-c", "ps aux | grep 'AmbariAgent.py' | grep ' \-v'"]
   cmdl = ["bash", "-c", "ps aux | grep 'AmbariAgent.py' | grep ' \--verbose'"]
   if execOsCommand(cmds)["exitstatus"] == 0 or execOsCommand(cmdl)["exitstatus"] == 0:
     verbose = True
-  subprocess.call("/usr/sbin/ambari-agent stop", shell=True)
   return verbose
 
 @OsFamilyFuncImpl(OSConst.WINSRV_FAMILY)
@@ -362,9 +363,9 @@ def run_setup(argv=None):
   return runAgent(passPhrase, expected_hostname, user_run_as, verbose)
 
 def main(argv=None):
-  #Try stop agent and check --verbose option if agent already run
+  #Check --verbose option if agent already running
   global verbose
-  verbose = tryStopAgent()
+  verbose = checkVerbose()
   if verbose:
     exitcode = run_setup(argv)
   else:

http://git-wip-us.apache.org/repos/asf/ambari/blob/2be054d1/ambari-server/src/test/python/TestSetupAgent.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestSetupAgent.py b/ambari-server/src/test/python/TestSetupAgent.py
index 80178ba..fbbce71 100644
--- a/ambari-server/src/test/python/TestSetupAgent.py
+++ b/ambari-server/src/test/python/TestSetupAgent.py
@@ -252,7 +252,7 @@ class TestSetupAgent(TestCase):
     self.assertFalse(setup_agent.execOsCommand("hostname -f") == None)
 
   @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
-  @patch.object(setup_agent, 'tryStopAgent')
+  @patch.object(setup_agent, 'checkVerbose')
   @patch.object(setup_agent, 'isAgentPackageAlreadyInstalled')
   @patch.object(setup_agent, 'runAgent')
   @patch.object(setup_agent, 'configureAgent')
@@ -267,14 +267,14 @@ class TestSetupAgent(TestCase):
   def test_setup_agent_main(self, dirname_mock, realpath_mock, exit_mock, checkServerReachability_mock,
                             getOptimalVersion_mock, is_ubuntu_family_mock, is_suse_family_mock,
                             installAgent_mock, configureAgent_mock, runAgent_mock,
-                            isAgentPackageAlreadyInstalled_mock, tryStopAgent_mock):
+                            isAgentPackageAlreadyInstalled_mock, checkVerbose_mock):
     checkServerReachability_mock.return_value = {'log': 'log', 'exitstatus': 0}
     installAgent_mock.return_value = {'log': 'log', 'exitstatus': 0}
     configureAgent_mock.return_value = {'log': 'log', 'exitstatus': 0}
     runAgent_mock.return_value = {'log': 'log', 'exitstatus': 0}
     getOptimalVersion_mock.return_value = {'log': '1.1.2, 1.1.3, ', 'exitstatus': 1}
     ret = setup_agent.main(("setupAgent.py","agents_host","password", "server_hostname","1.1.1","8080"))
-    self.assertTrue(tryStopAgent_mock.called)
+    self.assertTrue(checkVerbose_mock.called)
     self.assertFalse(exit_mock.called)
     self.assertTrue("exitstatus" in ret)
     self.assertEqual(ret["exitstatus"], 1)


Mime
View raw message