You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by an...@apache.org on 2025/09/30 04:52:13 UTC
(hadoop) branch branch-3.4 updated: HADOOP-19635. [ABFS][FnsOverBlob] Marker creation failure should not be propagated (#7825) (#7926)
This is an automated email from the ASF dual-hosted git repository.
anujmodi pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.4 by this push:
new c89bbb22d03 HADOOP-19635. [ABFS][FnsOverBlob] Marker creation failure should not be propagated (#7825) (#7926)
c89bbb22d03 is described below
commit c89bbb22d03afd9afe82d3b1e8828d2cee4da6d9
Author: Anmol Asrani <an...@gmail.com>
AuthorDate: Tue Sep 30 04:52:04 2025 +0000
HADOOP-19635. [ABFS][FnsOverBlob] Marker creation failure should not be propagated (#7825) (#7926)
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-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org