We're needlessly wrapping a `SnapshotMissingException` which itself is a `SnapshotException` when trying to load a missing snapshot. This leads to failure #47442 which expects a `SnapshotMissingException` in this case. Closes #47442
This commit is contained in:
parent
ea4069ca63
commit
5cef4752f7
|
@ -210,6 +210,9 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
|
||||||
if (ignoreUnavailable) {
|
if (ignoreUnavailable) {
|
||||||
logger.warn(() -> new ParameterizedMessage("failed to get snapshot [{}]", snapshotId), ex);
|
logger.warn(() -> new ParameterizedMessage("failed to get snapshot [{}]", snapshotId), ex);
|
||||||
} else {
|
} else {
|
||||||
|
if (ex instanceof SnapshotException) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
throw new SnapshotException(repositoryName, snapshotId, "Snapshot could not be read", ex);
|
throw new SnapshotException(repositoryName, snapshotId, "Snapshot could not be read", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,18 @@ package org.elasticsearch.snapshots;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.ActionFuture;
|
import org.elasticsearch.action.ActionFuture;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
||||||
|
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
|
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
|
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.cluster.SnapshotsInProgress;
|
import org.elasticsearch.cluster.SnapshotsInProgress;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
|
import org.elasticsearch.core.internal.io.IOUtils;
|
||||||
|
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -109,4 +114,23 @@ public class SnapshotStatusApisIT extends AbstractSnapshotIntegTestCase {
|
||||||
logger.info("--> wait for snapshot to finish");
|
logger.info("--> wait for snapshot to finish");
|
||||||
createSnapshotResponseActionFuture.actionGet();
|
createSnapshotResponseActionFuture.actionGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testExceptionOnMissingSnapBlob() throws IOException {
|
||||||
|
disableRepoConsistencyCheck("This test intentionally corrupts the repository");
|
||||||
|
|
||||||
|
logger.info("--> creating repository");
|
||||||
|
final Path repoPath = randomRepoPath();
|
||||||
|
assertAcked(client().admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(
|
||||||
|
Settings.builder().put("location", repoPath).build()));
|
||||||
|
|
||||||
|
logger.info("--> snapshot");
|
||||||
|
final CreateSnapshotResponse response =
|
||||||
|
client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).get();
|
||||||
|
|
||||||
|
logger.info("--> delete snap-${uuid}.dat file for this snapshot to simulate concurrent delete");
|
||||||
|
IOUtils.rm(repoPath.resolve(BlobStoreRepository.SNAPSHOT_PREFIX + response.getSnapshotInfo().snapshotId().getUUID() + ".dat"));
|
||||||
|
|
||||||
|
expectThrows(SnapshotMissingException.class, () -> client().admin().cluster()
|
||||||
|
.getSnapshots(new GetSnapshotsRequest("test-repo", new String[] {"test-snap"})).actionGet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue