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 2015/03/11 18:27:38 UTC

[1/2] ambari git commit: AMBARI-10030. SNameNode start fails on CentOS5 (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 fa1f08f7a -> 8f85e8c60
  refs/heads/trunk 928545392 -> c12bce3ac


AMBARI-10030. SNameNode start fails on CentOS5 (aonishuk)


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

Branch: refs/heads/trunk
Commit: c12bce3acce61d226a58a3aca482580e52fb9376
Parents: 9285453
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Mar 11 19:27:32 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Mar 11 19:27:32 2015 +0200

----------------------------------------------------------------------
 .../python/resource_management/core/sudo.py     | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c12bce3a/ambari-common/src/main/python/resource_management/core/sudo.py
----------------------------------------------------------------------
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 938e95b..13c32a1 100644
--- a/ambari-common/src/main/python/resource_management/core/sudo.py
+++ b/ambari-common/src/main/python/resource_management/core/sudo.py
@@ -22,6 +22,7 @@ Ambari Agent
 import os
 import tempfile
 from resource_management.core import shell
+from resource_management.core.logger import Logger
 
 # os.chown replacement
 def chown(path, owner, group):
@@ -104,12 +105,19 @@ def path_lexists(path):
 # os.stat
 def stat(path):
   class Stat:
+    RETRY_COUNT = 5
     def __init__(self, path):
-      # TODO: check this on Ubuntu
-      out = shell.checked_call(["stat", "-c", "%u %g %a", path], sudo=True)[1]
-      uid_str, gid_str, mode_str = out.split(' ')
-      self.st_uid = int(uid_str)
-      self.st_gid = int(gid_str)
-      self.st_mode = int(mode_str, 8)
-      
+      # Sometimes (on heavy load) stat call returns an empty output with zero return code
+      for i in range(0, self.RETRY_COUNT):
+        out = shell.checked_call(["stat", "-c", "%u %g %a", path], sudo=True)[1]
+        values = out.split(' ')
+        if len(values) == 3:
+          uid_str, gid_str, mode_str = values
+          self.st_uid, self.st_gid, self.st_mode = int(uid_str), int(gid_str), int(mode_str, 8)
+          break
+      else:
+        warning_message = "Can not parse a sudo stat call output: \"{0}\"".format(out)
+        Logger.warning(warning_message)
+        stat_val = os.stat(path)
+        self.st_uid, self.st_gid, self.st_mode = stat_val.st_uid, stat_val.st_gid, stat_val.st_mode & 07777
   return Stat(path)


[2/2] ambari git commit: AMBARI-10030. SNameNode start fails on CentOS5 (aonishuk)

Posted by ao...@apache.org.
AMBARI-10030. SNameNode start fails on CentOS5 (aonishuk)


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

Branch: refs/heads/branch-2.0.0
Commit: 8f85e8c609347484fe2c490a750e80eec1db9825
Parents: fa1f08f
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Mar 11 19:27:34 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Mar 11 19:27:34 2015 +0200

----------------------------------------------------------------------
 .../python/resource_management/core/sudo.py     | 22 +++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8f85e8c6/ambari-common/src/main/python/resource_management/core/sudo.py
----------------------------------------------------------------------
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 938e95b..13c32a1 100644
--- a/ambari-common/src/main/python/resource_management/core/sudo.py
+++ b/ambari-common/src/main/python/resource_management/core/sudo.py
@@ -22,6 +22,7 @@ Ambari Agent
 import os
 import tempfile
 from resource_management.core import shell
+from resource_management.core.logger import Logger
 
 # os.chown replacement
 def chown(path, owner, group):
@@ -104,12 +105,19 @@ def path_lexists(path):
 # os.stat
 def stat(path):
   class Stat:
+    RETRY_COUNT = 5
     def __init__(self, path):
-      # TODO: check this on Ubuntu
-      out = shell.checked_call(["stat", "-c", "%u %g %a", path], sudo=True)[1]
-      uid_str, gid_str, mode_str = out.split(' ')
-      self.st_uid = int(uid_str)
-      self.st_gid = int(gid_str)
-      self.st_mode = int(mode_str, 8)
-      
+      # Sometimes (on heavy load) stat call returns an empty output with zero return code
+      for i in range(0, self.RETRY_COUNT):
+        out = shell.checked_call(["stat", "-c", "%u %g %a", path], sudo=True)[1]
+        values = out.split(' ')
+        if len(values) == 3:
+          uid_str, gid_str, mode_str = values
+          self.st_uid, self.st_gid, self.st_mode = int(uid_str), int(gid_str), int(mode_str, 8)
+          break
+      else:
+        warning_message = "Can not parse a sudo stat call output: \"{0}\"".format(out)
+        Logger.warning(warning_message)
+        stat_val = os.stat(path)
+        self.st_uid, self.st_gid, self.st_mode = stat_val.st_uid, stat_val.st_gid, stat_val.st_mode & 07777
   return Stat(path)