This is an automated email from the ASF dual-hosted git repository.

anujmodi pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new b6da28f445b HADOOP-19635. ABFS: Marker creation failure should not be 
propagated (#7825)
b6da28f445b is described below

commit b6da28f445bbb9ba0921fe3768ef88def7f7af78
Author: Anmol Asrani <anmol.asrani...@gmail.com>
AuthorDate: Thu Jul 31 11:02:49 2025 +0000

    HADOOP-19635. ABFS: Marker creation failure should not be propagated (#7825)
    
    Contributed by Anmol Asrani
---
 .../fs/azurebfs/services/AbfsBlobClient.java       | 14 +++++++--
 .../fs/azurebfs/ITestAzureBlobFileSystemOauth.java | 34 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java
 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java
index 9e8a7927638..e9fbfe49dee 100644
--- 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java
+++ 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java
@@ -532,7 +532,7 @@ public AbfsRestOperation createPath(final String path,
    *
    * @throws AzureBlobFileSystemException if an error occurs during the 
operation.
    */
-  protected AbfsRestOperation createMarkerAtPath(final String path,
+  public AbfsRestOperation createMarkerAtPath(final String path,
       final String eTag,
       final ContextEncryptionAdapter contextEncryptionAdapter,
       final TracingContext tracingContext) throws AzureBlobFileSystemException 
{
@@ -1241,8 +1241,16 @@ public AbfsRestOperation getPathStatus(final String path,
       if (op.getResult().getStatusCode() == HTTP_NOT_FOUND
           && isImplicitCheckRequired && isNonEmptyDirectory(path, 
tracingContext)) {
         // Implicit path found.
-        // Create a marker blob at this path.
-        this.createMarkerAtPath(path, null, contextEncryptionAdapter, 
tracingContext);
+        // Create a marker blob at this path. Marker creation might fail due 
to permission issues, so we swallow exception in case of failure.
+        try {
+          this.createMarkerAtPath(path, null, contextEncryptionAdapter,
+              tracingContext);
+        } catch (AbfsRestOperationException exception) {
+          LOG.debug("Marker creation failed for path {} during getPathStatus. 
StatusCode: {}, ErrorCode: {}",
+              path,
+              exception.getStatusCode(),
+              exception.getErrorCode());
+        }
         AbfsRestOperation successOp = getSuccessOp(
             AbfsRestOperationType.GetPathStatus, HTTP_METHOD_HEAD,
             url, requestHeaders);
diff --git 
a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemOauth.java
 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemOauth.java
index f27e75839b7..f81afa24c2f 100644
--- 
a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemOauth.java
+++ 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemOauth.java
@@ -24,6 +24,7 @@
 
 import org.junit.Assume;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,6 +36,8 @@
 import org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys;
 import 
org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
 import org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode;
+import org.apache.hadoop.fs.azurebfs.security.ContextEncryptionAdapter;
+import org.apache.hadoop.fs.azurebfs.services.AbfsBlobClient;
 import org.apache.hadoop.fs.azurebfs.services.AuthType;
 import org.apache.hadoop.fs.azurebfs.utils.TracingContext;
 import org.apache.hadoop.io.IOUtils;
@@ -47,6 +50,7 @@
 import static 
org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_BLOB_DATA_READER_CLIENT_SECRET;
 import static 
org.apache.hadoop.fs.contract.ContractTestUtils.assertPathDoesNotExist;
 import static org.apache.hadoop.fs.contract.ContractTestUtils.assertPathExists;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
 
 /**
  * Test Azure Oauth with Blob Data contributor role and Blob Data Reader role.
@@ -167,6 +171,36 @@ public void testBlobDataReader() throws Exception {
 
   }
 
+  /*
+   * GetPathStatus with Blob Data Reader role should not throw an exception 
when marker creation fails due to permission issues.
+   * */
+  @Test
+  public void testGetPathStatusWithReader() throws Exception {
+    String clientId = 
this.getConfiguration().get(FS_AZURE_BLOB_DATA_READER_CLIENT_ID);
+    Assume.assumeTrue("Reader client id not provided", clientId != null);
+    String secret = 
this.getConfiguration().get(FS_AZURE_BLOB_DATA_READER_CLIENT_SECRET);
+    Assume.assumeTrue("Reader client secret not provided", secret != null);
+
+    Path existedFolderPath = path(EXISTED_FOLDER_PATH);
+    createAzCopyFolder(existedFolderPath);
+    final AzureBlobFileSystem fs = Mockito.spy(getBlobReader());
+
+    // Use abfsStore in this test to verify the  ERROR code in 
AbfsRestOperationException
+    AzureBlobFileSystemStore abfsStore = Mockito.spy(fs.getAbfsStore());
+    Mockito.doReturn(abfsStore).when(fs).getAbfsStore();
+    AbfsBlobClient abfsClient = 
Mockito.spy(abfsStore.getClientHandler().getBlobClient());
+    Mockito.doReturn(abfsClient).when(abfsStore).getClient();
+    TracingContext tracingContext = getTestTracingContext(fs, true);
+
+    // GETPATHSTATUS marker creation fail should not be propagated to the 
caller.
+    assertThatCode(() -> abfsStore.getPathStatus(existedFolderPath, 
tracingContext))
+        .as("Expected getPathStatus to complete without throwing an exception")
+        .doesNotThrowAnyException();
+    Mockito.verify(abfsClient, 
Mockito.times(1)).createMarkerAtPath(Mockito.anyString(), 
Mockito.nullable(String.class),
+        Mockito.nullable(ContextEncryptionAdapter.class),
+        Mockito.nullable(TracingContext.class));
+  }
+
   private void prepareFiles(Path existedFilePath, Path existedFolderPath) 
throws IOException {
     // create test files/folders to verify access control diff between
     // Blob data contributor and Blob data reader


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to