Skip to content

Commit b9a5b1b

Browse files
Remove Container Exists Check in 6.8 (#45440)
* We already removed this check in `7.x` and this is breaking tests in 6.8 because the check requires additional permissions that we don't give in CI and don't want to giveon Cloud -> I think it's safe to remove it here as well as it really serves no purpose * Closes #44712
1 parent 22dd667 commit b9a5b1b

File tree

4 files changed

+0
-34
lines changed

4 files changed

+0
-34
lines changed

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java

-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public void delete(BlobPath path) throws IOException {
9494
public void close() {
9595
}
9696

97-
public boolean containerExist() throws URISyntaxException, StorageException {
98-
return service.doesContainerExist(clientName, container);
99-
}
100-
10197
public boolean blobExists(String blob) throws URISyntaxException, StorageException {
10298
return service.blobExists(clientName, container, blob);
10399
}

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java

-19
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.apache.logging.log4j.LogManager;
2727
import org.apache.logging.log4j.Logger;
28-
import org.elasticsearch.cluster.metadata.MetaData;
2928
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
3029
import org.elasticsearch.common.Strings;
3130
import org.elasticsearch.common.blobstore.BlobPath;
@@ -35,13 +34,9 @@
3534
import org.elasticsearch.common.unit.ByteSizeValue;
3635
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
3736
import org.elasticsearch.env.Environment;
38-
import org.elasticsearch.repositories.IndexId;
3937
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
40-
import org.elasticsearch.snapshots.SnapshotCreationException;
41-
import org.elasticsearch.snapshots.SnapshotId;
4238

4339
import java.net.URISyntaxException;
44-
import java.util.List;
4540
import java.util.Locale;
4641
import java.util.function.Function;
4742

@@ -157,20 +152,6 @@ protected ByteSizeValue chunkSize() {
157152
return chunkSize;
158153
}
159154

160-
@Override
161-
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, MetaData clusterMetadata) {
162-
try {
163-
final AzureBlobStore blobStore = (AzureBlobStore) blobStore();
164-
if (blobStore.containerExist() == false) {
165-
throw new IllegalArgumentException("The bucket [" + blobStore + "] does not exist. Please create it before "
166-
+ " creating an azure snapshot repository backed by it.");
167-
}
168-
} catch (URISyntaxException | StorageException e) {
169-
throw new SnapshotCreationException(metadata.name(), snapshotId, e);
170-
}
171-
super.initializeSnapshot(snapshotId, indices, clusterMetadata);
172-
}
173-
174155
@Override
175156
public boolean isReadOnly() {
176157
return readonly;

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureStorageService.java

-6
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,6 @@ public Map<String, AzureStorageSettings> refreshAndClearCache(Map<String, AzureS
137137
return prevSettings;
138138
}
139139

140-
public boolean doesContainerExist(String account, String container) throws URISyntaxException, StorageException {
141-
final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client(account);
142-
final CloudBlobContainer blobContainer = client.v1().getContainerReference(container);
143-
return SocketAccess.doPrivilegedException(() -> blobContainer.exists(null, null, client.v2().get()));
144-
}
145-
146140
public void deleteFiles(String account, String container, String path) throws URISyntaxException, StorageException {
147141
final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client(account);
148142
// container name must be lower case.

plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureStorageServiceMock.java

-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ public AzureStorageServiceMock() {
5656
super(Settings.EMPTY);
5757
}
5858

59-
@Override
60-
public boolean doesContainerExist(String account, String container) {
61-
return true;
62-
}
63-
6459
@Override
6560
public void deleteFiles(String account, String container, String path) throws URISyntaxException, StorageException {
6661
final Map<String, BlobMetaData> blobs = listBlobsByPrefix(account, container, path, null);

0 commit comments

Comments
 (0)