Browse Source

HADOOP-15968. ABFS: add try catch for UGI failure when initializing ABFS.

Contributed by Da Zhou.

(cherry picked from commit a8bbd818d5bc4762324bcdb7cf1fdd5c2f93891b)
Da Zhou 6 years ago
parent
commit
2d2212a508

+ 6 - 1
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java

@@ -121,7 +121,12 @@ public class AzureBlobFileSystem extends FileSystem {
     }
     }
 
 
     if (!abfsConfiguration.getSkipUserGroupMetadataDuringInitialization()) {
     if (!abfsConfiguration.getSkipUserGroupMetadataDuringInitialization()) {
-      this.primaryUserGroup = userGroupInformation.getPrimaryGroupName();
+      try {
+        this.primaryUserGroup = userGroupInformation.getPrimaryGroupName();
+      } catch (IOException ex) {
+        LOG.error("Failed to get primary group for {}, using user name as primary group name", user);
+        this.primaryUserGroup = this.user;
+      }
     } else {
     } else {
       //Provide a default group name
       //Provide a default group name
       this.primaryUserGroup = this.user;
       this.primaryUserGroup = this.user;

+ 9 - 4
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java

@@ -102,8 +102,8 @@ public class AzureBlobFileSystemStore {
   private AbfsClient client;
   private AbfsClient client;
   private URI uri;
   private URI uri;
   private final UserGroupInformation userGroupInformation;
   private final UserGroupInformation userGroupInformation;
-  private final String userName;
-  private final String primaryUserGroup;
+  private String userName;
+  private String primaryUserGroup;
   private static final String DATE_TIME_PATTERN = "E, dd MMM yyyy HH:mm:ss 'GMT'";
   private static final String DATE_TIME_PATTERN = "E, dd MMM yyyy HH:mm:ss 'GMT'";
   private static final String XMS_PROPERTIES_ENCODING = "ISO-8859-1";
   private static final String XMS_PROPERTIES_ENCODING = "ISO-8859-1";
   private static final int LIST_MAX_RESULTS = 5000;
   private static final int LIST_MAX_RESULTS = 5000;
@@ -134,10 +134,15 @@ public class AzureBlobFileSystemStore {
     this.userName = userGroupInformation.getShortUserName();
     this.userName = userGroupInformation.getShortUserName();
 
 
     if (!abfsConfiguration.getSkipUserGroupMetadataDuringInitialization()) {
     if (!abfsConfiguration.getSkipUserGroupMetadataDuringInitialization()) {
-      primaryUserGroup = userGroupInformation.getPrimaryGroupName();
+      try {
+        this.primaryUserGroup = userGroupInformation.getPrimaryGroupName();
+      } catch (IOException ex) {
+        LOG.error("Failed to get primary group for {}, using user name as primary group name", userName);
+        this.primaryUserGroup = userName;
+      }
     } else {
     } else {
       //Provide a default group name
       //Provide a default group name
-      primaryUserGroup = userName;
+      this.primaryUserGroup = userName;
     }
     }
 
 
     this.azureAtomicRenameDirSet = new HashSet<>(Arrays.asList(
     this.azureAtomicRenameDirSet = new HashSet<>(Arrays.asList(