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 2018/09/26 09:46:31 UTC

[ambari] branch trunk updated (204e777 -> e64f3df)

This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git.


    from 204e777  AMBARI-24689. All component statuses should be re-send on registration (aonishuk)
     new 50d9550  AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)
     new e64f3df  AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../test/python/resource_management/TestLinkResource.py   |  2 +-
 .../python/resource_management/core/providers/system.py   | 15 +++++++++++----
 .../src/main/python/resource_management/core/source.py    |  2 +-
 .../src/main/python/resource_management/core/sudo.py      | 11 +++++++++--
 4 files changed, 22 insertions(+), 8 deletions(-)


[ambari] 02/02: AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)

Posted by ao...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit e64f3dfb2365cfdfa14db553b0d9b55a3e80f6e2
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Wed Sep 26 11:42:36 2018 +0300

    AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)
---
 ambari-agent/src/test/python/resource_management/TestLinkResource.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ambari-agent/src/test/python/resource_management/TestLinkResource.py b/ambari-agent/src/test/python/resource_management/TestLinkResource.py
index 221bf6b..6a1377b 100644
--- a/ambari-agent/src/test/python/resource_management/TestLinkResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestLinkResource.py
@@ -34,7 +34,7 @@ class TestLinkResource(TestCase):
 
   @patch.object(os.path, "realpath")
   @patch("resource_management.core.sudo.path_lexists")
-  @patch("resource_management.core.sudo.path_lexists")
+  @patch("resource_management.core.sudo.path_islink")
   @patch("resource_management.core.sudo.unlink")
   @patch("resource_management.core.sudo.symlink")
   def test_action_create_relink(self, symlink_mock, unlink_mock, 


[ambari] 01/02: AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)

Posted by ao...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 50d955084256a79c2b03599cfc0e3658779057d5
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Wed Sep 26 10:03:01 2018 +0300

    AMBARI-24670. Directory creation sometimes fails with parallel_execution=1 (aonishuk)
---
 .../python/resource_management/core/providers/system.py   | 15 +++++++++++----
 .../src/main/python/resource_management/core/source.py    |  2 +-
 .../src/main/python/resource_management/core/sudo.py      | 11 +++++++++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ambari-common/src/main/python/resource_management/core/providers/system.py b/ambari-common/src/main/python/resource_management/core/providers/system.py
index 6293436..95c12ad 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/system.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/system.py
@@ -172,7 +172,7 @@ class DirectoryProvider(Provider):
       if self.resource.follow:
         # Follow symlink until the tail.
         followed_links = set()
-        while sudo.path_lexists(path):
+        while sudo.path_islink(path):
           if path in followed_links:
             raise Fail("Applying %s failed, looped symbolic links found while resolving %s" % (self.resource, path))
           followed_links.add(path)
@@ -188,8 +188,15 @@ class DirectoryProvider(Provider):
         if not sudo.path_isdir(dirname):
           raise Fail("Applying %s failed, parent directory %s doesn't exist" % (self.resource, dirname))
         
-        sudo.makedir(path, self.resource.mode or 0755)
-      
+        try:
+          sudo.makedir(path, self.resource.mode or 0755)
+        except Exception as ex:
+          # race condition (somebody created the file before us)
+          if "File exists" in str(ex):
+            sudo.makedirs(path, self.resource.mode or 0755)
+          else:
+            raise
+
     if not sudo.path_isdir(path):
       raise Fail("Applying %s failed, file %s already exists" % (self.resource, path))
     
@@ -216,7 +223,7 @@ class LinkProvider(Provider):
       oldpath = os.path.realpath(path)
       if oldpath == self.resource.to:
         return
-      if not sudo.path_lexists(path):
+      if not sudo.path_islink(path):
         raise Fail(
           "%s trying to create a symlink with the same name as an existing file or directory" % self.resource)
       Logger.info("%s replacing old symlink to %s" % (self.resource, oldpath))
diff --git a/ambari-common/src/main/python/resource_management/core/source.py b/ambari-common/src/main/python/resource_management/core/source.py
index 32c5cad..a2b1598 100644
--- a/ambari-common/src/main/python/resource_management/core/source.py
+++ b/ambari-common/src/main/python/resource_management/core/source.py
@@ -72,7 +72,7 @@ class StaticFile(Source):
       basedir = self.env.config.basedir
       path = os.path.join(basedir, "files", self.name)
       
-    if not sudo.path_isfile(path) and not sudo.path_lexists(path):
+    if not sudo.path_isfile(path):
       raise Fail("{0} Source file {1} is not found".format(repr(self), path))
 
     return self.read_file(path)
diff --git a/ambari-common/src/main/python/resource_management/core/sudo.py b/ambari-common/src/main/python/resource_management/core/sudo.py
index f103c8d..990b293 100644
--- a/ambari-common/src/main/python/resource_management/core/sudo.py
+++ b/ambari-common/src/main/python/resource_management/core/sudo.py
@@ -159,7 +159,10 @@ if os.geteuid() == 0:
   
   def path_isdir(path):
     return os.path.isdir(path)
-  
+
+  def path_islink(path):
+    return os.path.islink(path)
+
   def path_lexists(path):
     return os.path.lexists(path)
   
@@ -267,10 +270,14 @@ else:
   # os.path.isdir
   def path_isdir(path):
     return (shell.call(["test", "-d", path], sudo=True)[0] == 0)
+
+  # os.path.islink
+  def path_islink(path):
+    return (shell.call(["test", "-L", path], sudo=True)[0] == 0)
   
   # os.path.lexists
   def path_lexists(path):
-    return (shell.call(["test", "-L", path], sudo=True)[0] == 0)
+    return (shell.call(["test", "-e", path], sudo=True)[0] == 0)
   
   # os.readlink
   def readlink(path):