Skip to content

Commit

Permalink
Remove Container Exists Check in 6.8 (#45440)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
original-brownbear authored Aug 12, 2019
1 parent 22dd667 commit b9a5b1b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ public void delete(BlobPath path) throws IOException {
public void close() {
}

public boolean containerExist() throws URISyntaxException, StorageException {
return service.doesContainerExist(clientName, container);
}

public boolean blobExists(String blob) throws URISyntaxException, StorageException {
return service.blobExists(clientName, container, blob);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.blobstore.BlobPath;
Expand All @@ -35,13 +34,9 @@
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.env.Environment;
import org.elasticsearch.repositories.IndexId;
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
import org.elasticsearch.snapshots.SnapshotCreationException;
import org.elasticsearch.snapshots.SnapshotId;

import java.net.URISyntaxException;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;

Expand Down Expand Up @@ -157,20 +152,6 @@ protected ByteSizeValue chunkSize() {
return chunkSize;
}

@Override
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, MetaData clusterMetadata) {
try {
final AzureBlobStore blobStore = (AzureBlobStore) blobStore();
if (blobStore.containerExist() == false) {
throw new IllegalArgumentException("The bucket [" + blobStore + "] does not exist. Please create it before "
+ " creating an azure snapshot repository backed by it.");
}
} catch (URISyntaxException | StorageException e) {
throw new SnapshotCreationException(metadata.name(), snapshotId, e);
}
super.initializeSnapshot(snapshotId, indices, clusterMetadata);
}

@Override
public boolean isReadOnly() {
return readonly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ public Map<String, AzureStorageSettings> refreshAndClearCache(Map<String, AzureS
return prevSettings;
}

public boolean doesContainerExist(String account, String container) throws URISyntaxException, StorageException {
final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client(account);
final CloudBlobContainer blobContainer = client.v1().getContainerReference(container);
return SocketAccess.doPrivilegedException(() -> blobContainer.exists(null, null, client.v2().get()));
}

public void deleteFiles(String account, String container, String path) throws URISyntaxException, StorageException {
final Tuple<CloudBlobClient, Supplier<OperationContext>> client = client(account);
// container name must be lower case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ public AzureStorageServiceMock() {
super(Settings.EMPTY);
}

@Override
public boolean doesContainerExist(String account, String container) {
return true;
}

@Override
public void deleteFiles(String account, String container, String path) throws URISyntaxException, StorageException {
final Map<String, BlobMetaData> blobs = listBlobsByPrefix(account, container, path, null);
Expand Down

0 comments on commit b9a5b1b

Please sign in to comment.