{"record":{"id":"c4142bf2bbcb5a99","repo":"apache/dolphinscheduler","slug":"k8stask-is-timeout","errorCode":null,"errorMessage":"K8sTask is timeout","messagePattern":"K8sTask is timeout","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/AbstractK8sTaskExecutor.java","lineNumber":57,"sourceCode":"        this.taskRequest = taskRequest;\n        this.k8sUtils = new K8sUtils();\n        this.yaml = new Yaml(new ClassFilterConstructor(new Class[]{\n                List.class,\n                String.class\n        }));\n        this.taskOutputParams = new HashMap<>();\n    }\n    public Map<String, String> getTaskOutputParams() {\n        return taskOutputParams;\n    }\n\n    public abstract TaskResponse run(String k8sParameterStr) throws Exception;\n\n    public abstract void cancelApplication(String k8sParameterStr);\n\n    public void waitTimeout(Boolean timeout) throws TaskException {\n        if (Boolean.TRUE.equals(timeout)) {\n            throw new TaskException(\"K8sTask is timeout\");\n        }\n    }\n\n    public abstract void submitJob2k8s(String k8sParameterStr);\n\n    public abstract void stopJobOnK8s(String k8sParameterStr);\n}\n","sourceCodeStart":39,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/k8s/AbstractK8sTaskExecutor.java#L39-L65","documentation":"AbstractK8sTaskExecutor.waitTimeout(Boolean) throws TaskException(\"K8sJobExecutor is timeout\") — here \"K8sTask is timeout\" — when the caller passes timeout=TRUE, i.e. the K8s task exceeded its configured timeout while waiting for the job to finish. It is the library's way of aborting a job that did not reach completion in time.","triggerScenarios":"The polling/watch loop in the concrete executor (K8sTaskExecutor.run) detects elapsed time >= taskTimeout and calls waitTimeout(true), or the task definition's timeout is smaller than the job's actual runtime.","commonSituations":"Long-running container images (big data jobs) with default/short timeout; slow image pulls consuming the budget; cluster resource starvation making pods Pending; timeout configured in the wrong unit.","solutions":["Increase the task's timeout setting in the task/workflow definition to exceed realistic job runtime.","Check why the job is slow: pod logs, image pull time, Pending pods due to insufficient cluster resources.","If the job legitimately runs long, split it or raise timeouts and resource limits.","Ensure failed timed-out jobs are cleaned up (stopJobOnK8s/cancelApplication) to avoid orphaned jobs."],"exampleFix":"// before\ntimeout = 60; // seconds, too small for the job\n// after\ntimeout = 3600; // sized to worst-case job runtime, incl. image pull","handlingStrategy":"validation","validationCode":"long estimatedRuntimeMs = estimateJobRuntime();\nif (taskTimeoutMs <= estimatedRuntimeMs) {\n    log.warn(\"Task timeout ({}) is close to/below expected runtime ({})\", taskTimeoutMs, estimatedRuntimeMs);\n}","typeGuard":null,"tryCatchPattern":"try {\n    response = executor.run(k8sParameterStr);\n} catch (TaskException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"timeout\")) {\n        log.warn(\"K8s job exceeded timeout; cleaning up job and retrying with larger timeout\");\n        executor.cancelApplication(k8sParameterStr);\n    }\n    throw e;\n}","preventionTips":["Size the task timeout to worst-case runtime including image pull and scheduling wait.","Alert on pods stuck in Pending — resource starvation commonly eats the timeout budget.","Clean up jobs on timeout (cancelApplication/stopJobOnK8s) to avoid orphaned resources."],"tags":["kubernetes","timeout","task-execution"],"backgroundTag":"request-timeout","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}