From e6451d66f4dce78247cb640cb4934f016d391220 Mon Sep 17 00:00:00 2001 From: Mani Date: Sun, 25 Jun 2023 16:40:45 +0530 Subject: [PATCH] Return 409 Conflict HTTP status instead of 500 on failure to concurrently execute snapshots Signed-off-by: Mani Return 409 Conflict HTTP status instead of 500 on failure to concurrently execute snapshots Signed-off-by: Mani another --- CHANGELOG.md | 1 + .../snapshots/ConcurrentSnapshotExecutionException.java | 2 +- .../test/java/org/opensearch/OpenSearchExceptionTests.java | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 861674753861a..dbce93adff60d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Remote Segment Store Repository setting moved from `index.remote_store.repository` to `index.remote_store.segment.repository` and `cluster.remote_store.repository` to `cluster.remote_store.segment.repository` respectively for Index and Cluster level settings ([#8719](https://github.com/opensearch-project/OpenSearch/pull/8719)) - [Remote Store] Add support to restore only unassigned shards of an index ([#8792](https://github.com/opensearch-project/OpenSearch/pull/8792)) - Replace the deprecated IndexReader APIs with new storedFields() & termVectors() ([#7792](https://github.com/opensearch-project/OpenSearch/pull/7792)) +- Return 409 Conflict HTTP status instead of 500 on failure to concurrently execute snapshots ([#5855](https://github.com/opensearch-project/OpenSearch/pull/5855)) ### Deprecated diff --git a/server/src/main/java/org/opensearch/snapshots/ConcurrentSnapshotExecutionException.java b/server/src/main/java/org/opensearch/snapshots/ConcurrentSnapshotExecutionException.java index e0b4d3bf49d2e..b2f07d4d62f59 100644 --- a/server/src/main/java/org/opensearch/snapshots/ConcurrentSnapshotExecutionException.java +++ b/server/src/main/java/org/opensearch/snapshots/ConcurrentSnapshotExecutionException.java @@ -58,6 +58,6 @@ public ConcurrentSnapshotExecutionException(StreamInput in) throws IOException { @Override public RestStatus status() { - return RestStatus.SERVICE_UNAVAILABLE; + return RestStatus.CONFLICT; } } diff --git a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java index ca94462160f23..a47dd67acfdff 100644 --- a/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java +++ b/server/src/test/java/org/opensearch/OpenSearchExceptionTests.java @@ -71,6 +71,7 @@ import org.opensearch.search.SearchParseException; import org.opensearch.search.SearchShardTarget; import org.opensearch.search.internal.ShardSearchContextId; +import org.opensearch.snapshots.ConcurrentSnapshotExecutionException; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.RemoteTransportException; @@ -119,6 +120,9 @@ public void testStatus() { exception = new RemoteTransportException("test", new IllegalStateException("foobar")); assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR)); + + exception = new ConcurrentSnapshotExecutionException("testRepo", "testSnap", "test"); + assertSame(exception.status(), RestStatus.CONFLICT); } public void testGuessRootCause() {