diff --git a/digdag-server/src/main/java/io/digdag/server/rs/AttemptResource.java b/digdag-server/src/main/java/io/digdag/server/rs/AttemptResource.java index a678e3e690..c739bf52ae 100644 --- a/digdag-server/src/main/java/io/digdag/server/rs/AttemptResource.java +++ b/digdag-server/src/main/java/io/digdag/server/rs/AttemptResource.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Set; +import java.util.Arrays; import java.util.HashSet; import java.util.stream.Collectors; import javax.ws.rs.Consumes; @@ -298,21 +299,24 @@ private List collectResumingTasks(RestSessionAttemptRequest.Resume resume) private List collectResumingTasksForResumeFailedMode(long attemptId) { + TaskStateCode[] statusArr = {TaskStateCode.SUCCESS, TaskStateCode.GROUP_ERROR, TaskStateCode.ERROR, TaskStateCode.CANCELED}; + List statuses = Arrays.asList(statusArr); + List tasks = sm .getSessionStore(getSiteId()) .getTasksOfAttempt(attemptId); - List successTasks = tasks.stream() - .filter(task -> task.getState() == TaskStateCode.SUCCESS) + List ids = tasks.stream() + .filter(t-> statuses.contains(t.getState())) .map(task -> { - if (!task.getParentId().isPresent()) { + if (!task.getParentId().isPresent() && task.getState() == TaskStateCode.SUCCESS) { throw new IllegalArgumentException("Resuming successfully completed attempts is not supported"); } return task.getId(); }) .collect(Collectors.toList()); - return ImmutableList.copyOf(successTasks); + return ImmutableList.copyOf(ids); } private List collectResumingTasksForResumeFromMode(long attemptId, String fromTaskPattern)