Browse Source

HUE-9281 [core] Users home directory becomes created with the wrong owner on LDAP environment (#1115)

* HUE-9281 [core] Users home directory becomes created with the wrong owner on LDAP environment

* HUE-9281 [core] Log the execption for chown(home_path, group=user)
Ivan Dzikovsky 5 years ago
parent
commit
48dc4465f7
1 changed files with 6 additions and 1 deletions
  1. 6 1
      desktop/libs/hadoop/src/hadoop/fs/hadoopfs.py

+ 6 - 1
desktop/libs/hadoop/src/hadoop/fs/hadoopfs.py

@@ -188,7 +188,12 @@ class Hdfs(object):
           self.setuser(self.superuser)
           self.mkdir(home_path)
           self.chmod(home_path, mode)
-          self.chown(home_path, user, user)
+          self.chown(home_path, user)
+          try:  # Handle the case when there is no group with the same name as the user.
+            self.chown(home_path, group=user)
+          except IOError:
+            LOG.exception('Failed to change the group of "{}" to "{}" when creating a home directory '
+                          'for user "{}"'.format(home_path, user, user))
         except IOError:
           msg = 'Failed to create home dir ("%s") as superuser %s' % (home_path, self.superuser)
           LOG.exception(msg)