anujmodi2021 commented on code in PR #8410:
URL: https://github.com/apache/hadoop/pull/8410#discussion_r3055444700


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java:
##########
@@ -422,17 +423,33 @@ private synchronized boolean 
getNamespaceEnabledInformationFromServer(
     } catch (AbfsRestOperationException ex) {
       // Get ACL status is a HEAD request, its response doesn't contain 
errorCode
       // So can only rely on its status code to determine account type.
-      if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) {
+      int status = ex.getStatusCode();
+      String message = ex.getMessage();
+
+      // Case 1: 409: Soft delete not supported
+      if (status == HttpURLConnection.HTTP_CONFLICT &&
+              message != null &&
+              message.contains(ERR_SOFT_DELETE_NOT_SUPPORTED)) {
+        /*
+         * HTTP_CONFLICT with soft delete not supported error indicates a FNS 
account.
+         * This occurs when:
+         * 1. FNS-Blob endpoint is used (used with DFS endpoint for getAcl 
call)
+         * 2. FNS-DFS endpoint is used (later internally converted to Blob)
+         * For both cases, namespace should be disabled. No need to throw 
exception.

Review Comment:
   Also add a line that for both cases ultimately Blob endpoint will be used so 
this error is irrelevant as it comes only on DFS Endpoint



##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java:
##########
@@ -422,17 +423,33 @@ private synchronized boolean 
getNamespaceEnabledInformationFromServer(
     } catch (AbfsRestOperationException ex) {
       // Get ACL status is a HEAD request, its response doesn't contain 
errorCode
       // So can only rely on its status code to determine account type.
-      if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) {
+      int status = ex.getStatusCode();
+      String message = ex.getMessage();
+
+      // Case 1: 409: Soft delete not supported
+      if (status == HttpURLConnection.HTTP_CONFLICT &&
+              message != null &&
+              message.contains(ERR_SOFT_DELETE_NOT_SUPPORTED)) {
+        /*
+         * HTTP_CONFLICT with soft delete not supported error indicates a FNS 
account.
+         * This occurs when:
+         * 1. FNS-Blob endpoint is used (used with DFS endpoint for getAcl 
call)

Review Comment:
   nit: used coming twice



##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestGetNameSpaceEnabled.java:
##########
@@ -274,8 +278,11 @@ private void 
ensureGetAclDetermineHnsStatusAccuratelyInternal(int statusCode,
     AbfsClient mockClient = mock(AbfsClient.class);
     
store.getAbfsConfiguration().setIsNamespaceEnabledAccountForTesting(Trilean.UNKNOWN);
     doReturn(mockClient).when(store).getClient(AbfsServiceType.DFS);
+    String errorMsg = statusCode == HTTP_CONFLICT
+            ? ERR_SOFT_DELETE_NOT_SUPPORTED
+            : Integer.toString(statusCode);
     AbfsRestOperationException ex = new AbfsRestOperationException(
-        statusCode, null, Integer.toString(statusCode), null);
+        statusCode, null, errorMsg, null);
     doThrow(ex).when(mockClient).getAclStatus(anyString(), 
any(TracingContext.class));
 
     if (isExceptionExpected) {

Review Comment:
   Need some more testing no just mock.
   I understand that we can't control account's soft-delete feature but let's 
run all the integration tests on an account where soft-delete is enabled if not 
already done.
   
   And in integration tests we can assert that if error code returned by server 
can either be Bad request of htp conflict.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to