Skip to content

Commit 42d2d6f

Browse files
committed
apply spot less
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 3b142c3 commit 42d2d6f

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java

-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.concurrent.ConcurrentLinkedQueue;
2727
import java.util.concurrent.CountDownLatch;
2828
import java.util.concurrent.atomic.AtomicBoolean;
29-
import java.util.function.Function;
3029
import java.util.function.Supplier;
3130

3231
import org.apache.commons.lang3.tuple.Pair;
@@ -253,8 +252,6 @@ private void checkDownstreamTaskBeforeDeleteModel(String modelId, Boolean isHidd
253252
if (countDownLatch.getCount() == 0) {
254253
if (noneBlocked.get()) {
255254
deleteModel(modelId, isHidden, actionListener);
256-
} else {
257-
actionListener.onFailure(new OpenSearchStatusException(String.join(". ", errorMessages), RestStatus.CONFLICT));
258255
}
259256
}
260257
}, e -> {
@@ -269,7 +266,6 @@ private void checkDownstreamTaskBeforeDeleteModel(String modelId, Boolean isHidd
269266
checkSearchPipelineBeforeDeleteModel(modelId, countDownActionListener);
270267
}
271268

272-
273269
private void deleteModel(String modelId, Boolean isHidden, ActionListener<DeleteResponse> actionListener) {
274270
DeleteRequest deleteRequest = new DeleteRequest(ML_MODEL_INDEX, modelId).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
275271
client.delete(deleteRequest, new ActionListener<>() {
@@ -360,7 +356,6 @@ private void checkPipelineBeforeDeleteModel(
360356

361357
}
362358

363-
364359
private void deleteModelChunksAndController(
365360
ActionListener<DeleteResponse> actionListener,
366361
String modelId,
@@ -472,7 +467,6 @@ private List<String> findDependentPipelinesEasy(Map<String, Object> allConfigMap
472467
return dependentPipelineConfigurations;
473468
}
474469

475-
476470
// This method is to go through the pipeline configs and the configuration is a map of string to objects.
477471
// Objects can be a list or a map. we will search exhaustively through the configuration for any match of the candidateId.
478472
private Boolean searchThroughConfig(Object searchCandidate, String candidateId) {

plugin/src/test/java/org/opensearch/ml/action/models/DeleteModelTransportActionTests.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,18 @@ public void testDeleteModel_BlockedBySearchPipelineAndIngestionPipeline() throws
211211

212212
deleteModelTransportAction.doExecute(null, mlModelDeleteRequest, actionListener);
213213
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
214-
verify(actionListener).onFailure(argumentCaptor.capture());
214+
verify(actionListener, times(2)).onFailure(argumentCaptor.capture());
215215
String totalErrorMessage = argumentCaptor.getValue().getMessage();
216216
String[] separateErrorMessages = totalErrorMessage.split("\\. ");
217217
Set<String> generateErrorMessages = new HashSet<>(List.of(separateErrorMessages));
218218
Set<String> expectedErrorMessages = new HashSet<>(List.of("1 ingest pipelines are still using this model, please delete or update the pipelines first: [ingest_1]", "1 search pipelines are still using this model, please delete or update the pipelines first: [search_1]"));
219-
assertEquals(expectedErrorMessages, generateErrorMessages);
219+
Boolean flag = false;
220+
for (String errorMessage : generateErrorMessages) {
221+
if (!expectedErrorMessages.contains(errorMessage)) {
222+
flag = true;
223+
}
224+
}
225+
assertEquals(flag, false);
220226
}
221227

222228
public void testDeleteModel_BlockedBySearchPipeline() throws IOException {

plugin/src/test/java/org/opensearch/ml/plugin/DummyWrongTool.java

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package org.opensearch.ml.plugin;
77

8-
import java.util.List;
98
import java.util.Map;
109

1110
import org.opensearch.core.action.ActionListener;

0 commit comments

Comments
 (0)