Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1FA09185A7 for ; Wed, 15 Jul 2015 13:29:18 +0000 (UTC) Received: (qmail 42101 invoked by uid 500); 15 Jul 2015 13:29:18 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 42073 invoked by uid 500); 15 Jul 2015 13:29:18 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 42064 invoked by uid 99); 15 Jul 2015 13:29:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2015 13:29:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E3CC8E04BE; Wed, 15 Jul 2015 13:29:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aonishuk@apache.org To: commits@ambari.apache.org Date: Wed, 15 Jul 2015 13:29:17 -0000 Message-Id: <7f63a48570e64bd292e55a04100dfcc7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ambari git commit: AMBARI-12418. Second confirmation of hosts fails under combination of umask and non-root user (aonishuk) 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 Authored: Wed Jul 15 16:29:06 2015 +0300 Committer: Andrew Onishuk 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"])