Skip to content

Commit

Permalink
Fix bug in InferenceUpgradeTestCase.getConfigsWithBreakingChangeHandl…
Browse files Browse the repository at this point in the history
…ing (elastic#118624)

We need to load the two fields from the same response. Otherwise, we can have a sort of race
where we load "endpoints" from pre-8.15 as empty and then load "models" from a post-8.15 node
also empty, resulting in an empty list because we took the wrong info from either response.

closes elastic#118163
  • Loading branch information
original-brownbear committed Dec 13, 2024
1 parent 64f5398 commit 0225d71
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static org.elasticsearch.core.Strings.format;

Expand Down Expand Up @@ -112,13 +111,10 @@ protected void put(String inferenceId, String modelConfig, TaskType taskType) th
@SuppressWarnings("unchecked")
// in version 8.15, there was a breaking change where "models" was renamed to "endpoints"
LinkedList<Map<String, Object>> getConfigsWithBreakingChangeHandling(TaskType testTaskType, String oldClusterId) throws IOException {

var response = get(testTaskType, oldClusterId);
LinkedList<Map<String, Object>> configs;
configs = new LinkedList<>(
(List<Map<String, Object>>) Objects.requireNonNullElse((get(testTaskType, oldClusterId).get("endpoints")), List.of())
);
configs.addAll(Objects.requireNonNullElse((List<Map<String, Object>>) get(testTaskType, oldClusterId).get("models"), List.of()));

configs = new LinkedList<>((List<Map<String, Object>>) response.getOrDefault("endpoints", List.of()));
configs.addAll((List<Map<String, Object>>) response.getOrDefault("models", List.of()));
return configs;
}
}

0 comments on commit 0225d71

Please sign in to comment.