Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

import fixture.azure.AzureHttpFixture;

import com.azure.core.exception.HttpResponseException;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.models.BlobStorageException;

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
Expand Down Expand Up @@ -188,8 +190,8 @@ public void testMultiBlockUpload() throws Exception {

public void testReadFromPositionLargerThanBlobLength() {
testReadFromPositionLargerThanBlobLength(
e -> asInstanceOf(BlobStorageException.class, e.getCause()).getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED
.getStatus()
e -> asInstanceOf(BlobStorageException.class, ExceptionsHelper.unwrap(e, HttpResponseException.class))
.getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

package org.elasticsearch.repositories.azure;

import com.azure.storage.blob.models.BlobStorageException;
import com.azure.core.exception.HttpResponseException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.util.Throwables;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.blobstore.BlobContainer;
Expand Down Expand Up @@ -69,13 +69,13 @@ private InputStream openInputStream(OperationPurpose purpose, String blobName, l
try {
return blobStore.getInputStream(blobKey, position, length);
} catch (Exception e) {
Throwable rootCause = Throwables.getRootCause(e);
if (rootCause instanceof BlobStorageException blobStorageException) {
if (blobStorageException.getStatusCode() == RestStatus.NOT_FOUND.getStatus()) {
if (ExceptionsHelper.unwrap(e, HttpResponseException.class) instanceof HttpResponseException httpResponseException) {
final var httpStatusCode = httpResponseException.getResponse().getStatusCode();
if (httpStatusCode == RestStatus.NOT_FOUND.getStatus()) {
throw new NoSuchFileException("Blob [" + blobKey + "] not found");
}
if (blobStorageException.getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()) {
throw new RequestedRangeNotSatisfiedException(blobKey, position, length == null ? -1 : length, blobStorageException);
if (httpStatusCode == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()) {
throw new RequestedRangeNotSatisfiedException(blobKey, position, length == null ? -1 : length, e);
}
}
throw new IOException("Unable to get input stream for blob [" + blobKey + "]", e);
Expand Down
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ tests:
- class: org.elasticsearch.xpack.security.authc.oidc.OpenIdConnectAuthIT
method: testAuthenticateWithImplicitFlow
issue: https://github.com/elastic/elasticsearch/issues/111191
- class: org.elasticsearch.repositories.azure.AzureBlobContainerRetriesTests
method: testReadNonexistentBlobThrowsNoSuchFileException
issue: https://github.com/elastic/elasticsearch/issues/111233
- class: org.elasticsearch.action.admin.indices.create.SplitIndexIT
method: testSplitIndexPrimaryTerm
issue: https://github.com/elastic/elasticsearch/issues/111282
Expand Down