Skip to content

Commit d186091

Browse files
committed
fail fs init if cpk config on non hns account
1 parent a386ac1 commit d186091

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import javax.annotation.Nullable;
4646

47+
import org.apache.commons.lang3.StringUtils;
4748
import org.apache.hadoop.classification.VisibleForTesting;
4849
import org.apache.hadoop.fs.impl.BackReference;
4950
import org.apache.hadoop.security.ProviderUtils;
@@ -211,6 +212,17 @@ public void initialize(URI uri, Configuration configuration)
211212
tracingHeaderFormat = abfsConfiguration.getTracingHeaderFormat();
212213
this.setWorkingDirectory(this.getHomeDirectory());
213214

215+
if (!getIsNamespaceEnabled(
216+
new TracingContext(clientCorrelationId, fileSystemId,
217+
FSOperationType.GET_FILESTATUS, tracingHeaderFormat, listener)) && (
218+
abfsConfiguration.createEncryptionContextProvider() != null
219+
|| StringUtils.isNotEmpty(
220+
abfsConfiguration.getEncodedClientProvidedEncryptionKey()))) {
221+
close();
222+
throw new PathIOException(
223+
"Non HNS account " + uri.getPath() + " can not have CPK configs enabled.");
224+
}
225+
214226
TracingContext tracingContext = new TracingContext(clientCorrelationId,
215227
fileSystemId, FSOperationType.CREATE_FILESYSTEM, tracingHeaderFormat, listener);
216228
if (abfsConfiguration.getCreateRemoteFileSystemDuringInitialization()) {

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsInvalidChecksumException;
4141
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsDriverException;
4242
import org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode;
43-
import org.apache.hadoop.fs.azurebfs.utils.NamespaceUtil;
4443
import org.apache.hadoop.fs.store.LogExactlyOnce;
4544
import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.Permissions;
4645
import org.apache.hadoop.fs.azurebfs.extensions.EncryptionContextProvider;
@@ -120,7 +119,6 @@ public class AbfsClient implements Closeable {
120119
private final AbfsThrottlingIntercept intercept;
121120

122121
private final ListeningScheduledExecutorService executorService;
123-
private Boolean isNamespaceEnabled;
124122

125123
private boolean renameResilience;
126124

@@ -305,9 +303,6 @@ private void addEncryptionKeyRequestHeaders(String path,
305303
List<AbfsHttpHeader> requestHeaders, boolean isCreateFileRequest,
306304
ContextEncryptionAdapter contextEncryptionAdapter, TracingContext tracingContext)
307305
throws AzureBlobFileSystemException {
308-
if (!getIsNamespaceEnabled(tracingContext)) {
309-
return;
310-
}
311306
String encodedKey, encodedKeySHA256;
312307
switch (encryptionType) {
313308
case GLOBAL_KEY:
@@ -1486,15 +1481,6 @@ public synchronized String getAccessToken() throws IOException {
14861481
}
14871482
}
14881483

1489-
private synchronized Boolean getIsNamespaceEnabled(TracingContext tracingContext)
1490-
throws AzureBlobFileSystemException {
1491-
if (isNamespaceEnabled == null) {
1492-
setIsNamespaceEnabled(NamespaceUtil.isNamespaceEnabled(this,
1493-
tracingContext));
1494-
}
1495-
return isNamespaceEnabled;
1496-
}
1497-
14981484
protected Boolean getIsPaginatedDeleteEnabled() {
14991485
return abfsConfiguration.isPaginatedDeleteEnabled();
15001486
}
@@ -1684,11 +1670,6 @@ void setEncryptionContextProvider(EncryptionContextProvider provider) {
16841670
encryptionContextProvider = provider;
16851671
}
16861672

1687-
@VisibleForTesting
1688-
void setIsNamespaceEnabled(final Boolean isNamespaceEnabled) {
1689-
this.isNamespaceEnabled = isNamespaceEnabled;
1690-
}
1691-
16921673
/**
16931674
* Getter for abfsCounters from AbfsClient.
16941675
* @return AbfsCounters instance.

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/AbstractAbfsIntegrationTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ public void setup() throws Exception {
209209
wasb = new NativeAzureFileSystem(azureNativeFileSystemStore);
210210
wasb.initialize(wasbUri, rawConfig);
211211
}
212-
// Todo: To be fixed in HADOOP-19137
213-
AbfsClientUtils.setIsNamespaceEnabled(abfs.getAbfsClient(), true);
214212
}
215213

216214
@After

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ public void testCreateFileOverwrite(boolean enableConditionalCreateOverwrite)
281281
final AzureBlobFileSystem fs =
282282
(AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
283283
config);
284-
AbfsClientUtils.setIsNamespaceEnabled(fs.getAbfsClient(), true);
285284

286285
long totalConnectionMadeBeforeTest = fs.getInstrumentationMap()
287286
.get(CONNECTIONS_MADE.getStatName());

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/AbfsClientUtils.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public final class AbfsClientUtils {
2626
private AbfsClientUtils() {
2727

2828
}
29-
public static void setIsNamespaceEnabled(final AbfsClient abfsClient, final Boolean isNamespaceEnabled) {
30-
abfsClient.setIsNamespaceEnabled(isNamespaceEnabled);
31-
}
3229

3330
public static void setEncryptionContextProvider(final AbfsClient abfsClient, final EncryptionContextProvider provider) {
3431
abfsClient.setEncryptionContextProvider(provider);

0 commit comments

Comments
 (0)