ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject [39/50] [abbrv] ambari git commit: AMBARI-21531. Client component restart fails after Ambari upgrade while running custom hook script on Suse 11 (aonishuk)
Date Sun, 23 Jul 2017 23:34:12 GMT
AMBARI-21531. Client component restart fails after Ambari upgrade while running custom hook
script on Suse 11 (aonishuk)


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 8c15965e090c1666702d08b860a796015c79f679
Parents: 587c42d
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Jul 20 13:27:40 2017 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Jul 20 13:27:40 2017 +0300

----------------------------------------------------------------------
 .../resource_management/TestUserResource.py     |  2 +-
 .../python/resource_management/core/base.py     | 11 +++++
 .../core/providers/accounts.py                  |  6 ++-
 .../core/resources/accounts.py                  |  4 +-
 .../before-ANY/scripts/shared_initialization.py | 12 +++---
 .../2.0.6/hooks/before-ANY/test_before_any.py   | 45 +++++++++++++-------
 6 files changed, 55 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-agent/src/test/python/resource_management/TestUserResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestUserResource.py b/ambari-agent/src/test/python/resource_management/TestUserResource.py
index 97d992e..8f1df83 100644
--- a/ambari-agent/src/test/python/resource_management/TestUserResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestUserResource.py
@@ -163,7 +163,7 @@ class TestUserResource(TestCase):
     getpwnam_mock.return_value = _get_user_entity()
 
     with Environment('/') as env:
-      user = User("mapred", action = "create", uid = "1", shell = "/bin/bash")
+      user = User("mapred", action = "create", uid = 1, shell = "/bin/bash")
 
     popen_mock.assert_called_with(['/bin/bash', '--login', '--noprofile', '-c', "ambari-sudo.sh
 PATH=/bin -H -E usermod -s /bin/bash -u 1 mapred"], shell=False, preexec_fn=preexec_fn, stderr=-2,
stdout=-1, env={'PATH': '/bin'}, cwd=None, close_fds=True)
     self.assertEqual(popen_mock.call_count, 1)

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-common/src/main/python/resource_management/core/base.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/base.py b/ambari-common/src/main/python/resource_management/core/base.py
index 1500e1f..b862853 100644
--- a/ambari-common/src/main/python/resource_management/core/base.py
+++ b/ambari-common/src/main/python/resource_management/core/base.py
@@ -58,6 +58,17 @@ class BooleanArgument(ResourceArgument):
         "Expected a boolean for %s received %r" % (self.name, value))
     return value
 
+class IntegerArgument(ResourceArgument):
+  def validate(self, value):
+    if value is None:
+      return value
+
+    value = super(IntegerArgument, self).validate(value)
+    if not isinstance( value, int ):
+      raise InvalidArgument(
+        "Expected an integer for %s received %r" % (self.name, value))
+    return value
+
 
 class PasswordArgument(ResourceArgument):
   def log_str(self, key, value):

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-common/src/main/python/resource_management/core/providers/accounts.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/accounts.py
b/ambari-common/src/main/python/resource_management/core/providers/accounts.py
index c4f2496..fa70989 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/accounts.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/accounts.py
@@ -66,7 +66,9 @@ class UserProvider(Provider):
         groups = self.resource.groups
         if self.user and self.user_groups:
           groups += self.user_groups
-        option_value = ",".join(groups)
+        option_value = ",".join(groups) 
+      elif attributes[1] == "-u" and self.user and self.user.pw_uid == getattr(self.resource,
option_name):
+        option_value = None
       else:
         option_value = getattr(self.resource, option_name)
         
@@ -78,7 +80,7 @@ class UserProvider(Provider):
       return
 
     command.append(self.resource.username)
-
+    
     shell.checked_call(command, sudo=True)
 
   def action_remove(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-common/src/main/python/resource_management/core/resources/accounts.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/resources/accounts.py
b/ambari-common/src/main/python/resource_management/core/resources/accounts.py
index 4ee2c57..fb3f35a 100644
--- a/ambari-common/src/main/python/resource_management/core/resources/accounts.py
+++ b/ambari-common/src/main/python/resource_management/core/resources/accounts.py
@@ -21,7 +21,7 @@ Ambari Agent
 """
 __all__ = ["Group", "User"]
 
-from resource_management.core.base import Resource, ForcedListArgument, ResourceArgument,
BooleanArgument
+from resource_management.core.base import Resource, ForcedListArgument, ResourceArgument,
BooleanArgument, IntegerArgument
 
 
 class Group(Resource):
@@ -37,7 +37,7 @@ class User(Resource):
   action = ForcedListArgument(default="create")
   username = ResourceArgument(default=lambda obj: obj.name)
   comment = ResourceArgument()
-  uid = ResourceArgument()
+  uid = IntegerArgument()
   gid = ResourceArgument()
   """
   If the user exists, and there are some groups, appends to existant

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
index bcc1a3a..b687229 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
@@ -49,11 +49,13 @@ def setup_users():
              uid = get_uid(user),
              gid = params.user_to_gid_dict[user],
              groups = params.user_to_groups_dict[user],
+             fetch_nonlocal_groups = params.fetch_nonlocal_groups,
              )
       else:
         User(user,
              gid = params.user_to_gid_dict[user],
              groups = params.user_to_groups_dict[user],
+             fetch_nonlocal_groups = params.fetch_nonlocal_groups,
              )
 
     if params.override_uid == "true":
@@ -96,7 +98,7 @@ def create_dfs_cluster_admins():
 
   User(params.hdfs_user,
     groups = params.user_to_groups_dict[params.hdfs_user] + groups_list,
-          fetch_nonlocal_groups = params.fetch_nonlocal_groups
+    fetch_nonlocal_groups = params.fetch_nonlocal_groups
   )
 
 def create_tez_am_view_acls():
@@ -145,7 +147,7 @@ def set_uid(user, user_dirs):
        mode=0555)
   ignore_groupsusers_create_str = str(params.ignore_groupsusers_create).lower()
   uid = get_uid(user)
-  Execute(format("{tmp_dir}/changeUid.sh {user} {user_dirs} {uid}"),
+  Execute(format("{tmp_dir}/changeUid.sh {user} {user_dirs} {new_uid}", new_uid=0 if uid
is None else uid),
           not_if = format("(test $(id -u {user}) -gt 1000) || ({ignore_groupsusers_create_str})"))
 
 def get_uid(user):
@@ -161,12 +163,12 @@ def get_uid(user):
     return uid
   else:
     if user == params.smoke_user:
-      return 0
+      return None
     File(format("{tmp_dir}/changeUid.sh"),
          content=StaticFile("changeToSecureUid.sh"),
          mode=0555)
-    conde, newUid = shell.call((format("{tmp_dir}/changeUid.sh"), format("{user}")), sudo=True)
-    return newUid
+    code, newUid = shell.call(format("{tmp_dir}/changeUid.sh {user}"))
+    return int(newUid)
 
 def setup_hadoop_env():
   import params

http://git-wip-us.apache.org/repos/asf/ambari/blob/8c15965e/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
index 1d2351f..a13ac24 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/hooks/before-ANY/test_before_any.py
@@ -58,8 +58,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'hive',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -67,8 +68,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'oozie',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'users'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -76,13 +78,15 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'nobody',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'nobody'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('User', 'ambari-qa',
                               gid = 'hadoop',
-                              uid = 0,
+                              uid = None,
                               groups = [u'users'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -90,8 +94,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'flume',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -99,8 +104,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'hdfs',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -108,8 +114,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'storm',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -117,8 +124,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'mapred',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -126,8 +134,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'hbase',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -135,8 +144,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'tez',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'users'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -144,8 +154,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'zookeeper',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -153,8 +164,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'falcon',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'users'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -162,8 +174,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'sqoop',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -171,8 +184,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'yarn',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),
@@ -180,8 +194,9 @@ class TestHookBeforeInstall(RMFTestCase):
                               )
     self.assertResourceCalled('User', 'hcat',
                               gid = 'hadoop',
-                              uid = '1000',
+                              uid = 1000,
                               groups = [u'hadoop'],
+                              fetch_nonlocal_groups = True,
                               )
     self.assertResourceCalled('File', '/tmp/changeUid.sh',
                               content = StaticFile('changeToSecureUid.sh'),


Mime
View raw message