Skip to content

Commit 3dd042e

Browse files
authored
Fix stopping issue when forecaster is in FORECAST_FAILURE state (#1502)
Mark FORECAST_FAILURE as a non-ending state so TaskManager recognizes the task as stoppable. Previously, TaskManager.stopLatestRealtimeTask failed to stop the task, as `isDone()` returned false for FORECAST_FAILURE, causing a "job is already stopped" error. Testing: - Manually verified forecaster can now be stopped successfully from FORECAST_FAILURE state. Signed-off-by: Kaituo Li <kaituo@amazon.com>
1 parent 08dceb4 commit 3dd042e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

release-notes/opensearch-anomaly-detection.release-notes-3.1.0.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Compatible with OpenSearch 3.1.0
1010
- Fix incorrect task state handling in ForecastRunOnceTransportAction ([#1489](https://github.com/opensearch-project/anomaly-detection/pull/1489))
1111
- Fix incorrect task state handling in ForecastRunOnceTransportAction ([#1493](https://github.com/opensearch-project/anomaly-detection/pull/1493))
1212
- Refine cold-start, window delay, and task updates ([#1496](https://github.com/opensearch-project/anomaly-detection/pull/1496))
13+
- Fix stopping issue when forecaster is in FORECAST_FAILURE state ([#1502](https://github.com/opensearch-project/anomaly-detection/pull/1502))
1314

src/main/java/org/opensearch/timeseries/model/TaskState.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public String getDescription() {
9090
TaskState.RUNNING.name(),
9191
INIT_TEST.name(),
9292
AWAITING_DATA_TO_INIT.name(),
93-
AWAITING_DATA_TO_RESTART.name()
93+
AWAITING_DATA_TO_RESTART.name(),
94+
FORECAST_FAILURE.name()
9495
);
9596

9697
public static boolean isAwaitState(String state) {

src/test/java/org/opensearch/timeseries/model/TaskStateTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ public void testNotEndedStatesConstant() {
3131
List<String> list = TaskState.NOT_ENDED_STATES;
3232

3333
// expected size and membership
34-
assertEquals(6, list.size());
34+
assertEquals(7, list.size());
3535
assertTrue(list.contains(TaskState.CREATED.name()));
3636
assertTrue(list.contains(TaskState.INIT.name()));
3737
assertTrue(list.contains(TaskState.RUNNING.name()));
3838
assertTrue(list.contains(TaskState.INIT_TEST.name()));
3939
assertTrue(list.contains(TaskState.AWAITING_DATA_TO_INIT.name()));
4040
assertTrue(list.contains(TaskState.AWAITING_DATA_TO_RESTART.name()));
41+
assertTrue(list.contains(TaskState.FORECAST_FAILURE.name()));
4142

4243
// an obviously ended state must be absent
4344
assertFalse(list.contains(TaskState.FINISHED.name()));

0 commit comments

Comments
 (0)