ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] ambari git commit: AMBARI-12418. Second confirmation of hosts fails under combination of umask and non-root user (aonishuk)
Date Wed, 15 Jul 2015 13:29:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 f4dbcbae4 -> 16912e59e
  refs/heads/trunk 86b7bb55e -> 29e5c5605


AMBARI-12418. Second confirmation of hosts fails under combination of umask and non-root user
(aonishuk)


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

Branch: refs/heads/trunk
Commit: 29e5c5605e0e160e43ae57c228b16141a8bdc63b
Parents: 86b7bb5
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Wed Jul 15 16:29:06 2015 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Wed Jul 15 16:29:06 2015 +0300

----------------------------------------------------------------------
 ambari-server/src/main/python/bootstrap.py     | 14 +++++++++++++-
 ambari-server/src/test/python/TestBootstrap.py | 11 +++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/29e5c560/ambari-server/src/main/python/bootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/bootstrap.py b/ambari-server/src/main/python/bootstrap.py
index 95ad4d1..accee81 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -479,6 +479,9 @@ class BootstrapDefault(Bootstrap):
   def getAptUpdateCommand(self):
     return "sudo apt-get update -o Dir::Etc::sourcelist=\"%s/%s\" -o API::Get::List-Cleanup=\"0\"
--no-list-cleanup" %\
           ("sources.list.d", self.AMBARI_REPO_FILENAME)
+          
+  def getRepoFileChmodCommand(self):
+    return "sudo chmod 644 {0}".format(self.getRepoFile())
 
   def copyNeededFiles(self):
     # Copying the files
@@ -502,6 +505,15 @@ class BootstrapDefault(Bootstrap):
               params.bootdir, self.host_log)
     retcode2 = ssh.run()
     self.host_log.write("\n")
+    
+    # Change permissions on ambari.repo
+    self.host_log.write("==========================\n")
+    self.host_log.write("Changing permissions for ambari.repo...")
+    command = self.getRepoFileChmodCommand()
+    ssh = SSH(params.user, params.sshkey_file, self.host, command,
+              params.bootdir, self.host_log)
+    retcode4 = ssh.run()
+    self.host_log.write("\n")
 
     # Update repo cache for ubuntu OS
     if OSCheck.is_ubuntu_family():
@@ -522,7 +534,7 @@ class BootstrapDefault(Bootstrap):
     retcode3 = scp.run()
     self.host_log.write("\n")
 
-    return max(retcode1["exitstatus"], retcode2["exitstatus"], retcode3["exitstatus"])
+    return max(retcode1["exitstatus"], retcode2["exitstatus"], retcode3["exitstatus"], retcode4["exitstatus"])
 
   def getAmbariPort(self):
     server_port = self.shared_state.server_port

http://git-wip-us.apache.org/repos/asf/ambari/blob/29e5c560/ambari-server/src/test/python/TestBootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestBootstrap.py b/ambari-server/src/test/python/TestBootstrap.py
index 9c0e78e..bfeaa2f 100644
--- a/ambari-server/src/test/python/TestBootstrap.py
+++ b/ambari-server/src/test/python/TestBootstrap.py
@@ -438,11 +438,12 @@ class TestBootstrap(TestCase):
     expected1 = {"exitstatus": 42, "log": "log42", "errormsg": "errorMsg"}
     expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     expected3 = {"exitstatus": 1, "log": "log1", "errormsg": "errorMsg"}
+    expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     scp_init_mock.return_value = None
     ssh_init_mock.return_value = None
     # Testing max retcode return
     scp_run_mock.side_effect = [expected1, expected3]
-    ssh_run_mock.side_effect = [expected2]
+    ssh_run_mock.side_effect = [expected2, expected4]
     res = bootstrap_obj.copyNeededFiles()
     self.assertEquals(res, expected1["exitstatus"])
     input_file = str(scp_init_mock.call_args[0][3])
@@ -450,21 +451,23 @@ class TestBootstrap(TestCase):
     self.assertEqual(input_file, "setupAgentFile")
     self.assertEqual(remote_file, "RemoteName")
     command = str(ssh_init_mock.call_args[0][3])
-    self.assertEqual(command, "MoveRepoFileCommand")
+    self.assertEqual(command, "sudo chmod 644 RepoFile")
     # Another order
     expected1 = {"exitstatus": 0, "log": "log0", "errormsg": "errorMsg"}
     expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     expected3 = {"exitstatus": 1, "log": "log1", "errormsg": "errorMsg"}
+    expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     scp_run_mock.side_effect = [expected1, expected3]
-    ssh_run_mock.side_effect = [expected2]
+    ssh_run_mock.side_effect = [expected2, expected4]
     res = bootstrap_obj.copyNeededFiles()
     self.assertEquals(res, expected2["exitstatus"])
     # yet another order
     expected1 = {"exitstatus": 33, "log": "log33", "errormsg": "errorMsg"}
     expected2 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     expected3 = {"exitstatus": 42, "log": "log42", "errormsg": "errorMsg"}
+    expected4 = {"exitstatus": 17, "log": "log17", "errormsg": "errorMsg"}
     scp_run_mock.side_effect = [expected1, expected3]
-    ssh_run_mock.side_effect = [expected2]
+    ssh_run_mock.side_effect = [expected2, expected4]
     res = bootstrap_obj.copyNeededFiles()
     self.assertEquals(res, expected3["exitstatus"])
 


Mime
View raw message