diff --git a/src/main/java/org/opensearch/flowframework/util/WorkflowTimeoutUtility.java b/src/main/java/org/opensearch/flowframework/util/WorkflowTimeoutUtility.java index 4991e049..e5956e92 100644 --- a/src/main/java/org/opensearch/flowframework/util/WorkflowTimeoutUtility.java +++ b/src/main/java/org/opensearch/flowframework/util/WorkflowTimeoutUtility.java @@ -18,6 +18,7 @@ import org.opensearch.flowframework.transport.GetWorkflowStateAction; import org.opensearch.flowframework.transport.GetWorkflowStateRequest; import org.opensearch.flowframework.transport.WorkflowResponse; +import org.opensearch.search.aggregations.metrics.Min; import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; @@ -32,7 +33,7 @@ public class WorkflowTimeoutUtility { private static final Logger logger = LogManager.getLogger(WorkflowTimeoutUtility.class); private static final TimeValue MAX_TIMEOUT_MILLIS = TimeValue.timeValueSeconds(300); - + private static final TimeValue MIN_TIMEOUT_MILLIS = TimeValue.timeValueSeconds(1); /** * Schedules a timeout task for a workflow execution. * @@ -53,6 +54,7 @@ public static ActionListener scheduleTimeoutHandler( AtomicBoolean isResponseSent ) { long adjustedTimeout = Math.min(timeout, MAX_TIMEOUT_MILLIS.millis()); + adjustedTimeout = Math.max(adjustedTimeout, MIN_TIMEOUT_MILLIS.millis()); Scheduler.ScheduledCancellable scheduledCancellable = threadPool.schedule( new WorkflowTimeoutListener(client, workflowId, listener, isResponseSent), TimeValue.timeValueMillis(adjustedTimeout),