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 @@ -8,6 +8,7 @@
package org.elasticsearch.xpack.inference.integration;

import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.ResourceAlreadyExistsException;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ActionListener;
Expand Down Expand Up @@ -906,7 +907,7 @@ public void testStoreModel_ThrowsException_WhenFailureIsAVersionConflict() {
var model = TestModel.createRandomInstance();
assertStoreModel(modelRegistry, model);

var exception = expectThrows(ElasticsearchStatusException.class, () -> assertStoreModel(modelRegistry, model));
var exception = expectThrows(ResourceAlreadyExistsException.class, () -> assertStoreModel(modelRegistry, model));
assertThat(exception.status(), Matchers.is(RestStatus.BAD_REQUEST));
assertThat(
exception.getMessage(),
Expand Down Expand Up @@ -941,7 +942,7 @@ public void testStoreModel_DoesNotDeleteIndexDocs_WhenModelAlreadyExists() {
PlainActionFuture<Boolean> secondStoreListener = new PlainActionFuture<>();
modelRegistry.storeModel(model, secondStoreListener, TimeValue.THIRTY_SECONDS);

var exception = expectThrows(ElasticsearchStatusException.class, () -> secondStoreListener.actionGet(TimeValue.THIRTY_SECONDS));
var exception = expectThrows(ResourceAlreadyExistsException.class, () -> secondStoreListener.actionGet(TimeValue.THIRTY_SECONDS));
assertThat(exception.getMessage(), containsString("already exists"));
assertThat(exception.status(), Matchers.is(RestStatus.BAD_REQUEST));
assertIndicesContainExpectedDocsCount(model, 2);
Expand All @@ -964,7 +965,7 @@ private void storeCorruptedModelThenStoreModel(boolean storeSecrets) {
PlainActionFuture<Boolean> storeListener = new PlainActionFuture<>();
modelRegistry.storeModel(model, storeListener, TimeValue.THIRTY_SECONDS);

var exception = expectThrows(ElasticsearchStatusException.class, () -> storeListener.actionGet(TimeValue.THIRTY_SECONDS));
var exception = expectThrows(ResourceAlreadyExistsException.class, () -> storeListener.actionGet(TimeValue.THIRTY_SECONDS));
assertThat(exception.getMessage(), containsString("already exists"));
assertThat(exception.status(), Matchers.is(RestStatus.BAD_REQUEST));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,7 @@ private void storeModel(Model model, boolean updateClusterState, ActionListener<

var failureItem = firstFailureResponse.get();
if (ExceptionsHelper.unwrapCause(failureItem.failureCause()) instanceof VersionConflictEngineException) {
delegate.onFailure(
new ElasticsearchStatusException(
"Inference endpoint [{}] already exists",
RestStatus.BAD_REQUEST,
failureItem.failureCause(),
failureItem.inferenceId()
)
);
delegate.onFailure(new ResourceAlreadyExistsException("Inference endpoint [{}] already exists", failureItem.inferenceId()));
return;
}

Expand Down