apache/dolphinscheduler · error · TaskException
fail to check job:
Error message
fail to check job:
What it means
K8sUtils.jobExist() performs a GET on a Batch/V1 Job and wraps any client exception in a TaskException 'fail to check job: ' (note the message has a trailing space and does not append the job name). It signals the existence-check itself failed — not that the job is missing (a missing job returns false).
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/K8sUtils.java:70
public void deleteJob(String jobName, String namespace) {
try {
client.batch()
.v1()
.jobs()
.inNamespace(namespace)
.withName(jobName)
.delete();
} catch (Exception e) {
throw new TaskException("fail to delete job", e);
}
}
public Boolean jobExist(String jobName, String namespace) {
try {
Job job = client.batch().v1().jobs().inNamespace(namespace).withName(jobName).get();
return job != null;
} catch (Exception e) {
throw new TaskException("fail to check job: ", e);
}
}
public Watch createBatchJobWatcher(String jobName, Watcher<Job> watcher) {
try {
return client.batch()
.v1()
.jobs()
.withName(jobName)
.watch(watcher);
} catch (Exception e) {
throw new TaskException("fail to register batch job watcher", e);
}
}
public String getPodLog(String jobName, String namespace) {
try {
List<Pod> podList = client.pods().inNamespace(namespace).list().getItems();View on GitHub (pinned to 02eac45a1b)
Solutions
- Inspect the wrapped cause in logs to distinguish connectivity vs RBAC errors.
- Ensure buildClient(configYaml) succeeded before calling jobExist.
- Test access with kubectl auth can-i get jobs -n <namespace> using the same credentials.
- Confirm the namespace name is correct and active.
Example fix
// before Boolean exists = k8sUtils.jobExist(jobName, namespace); // may throw // after k8sUtils.buildClient(kubeconfigYaml); // build/validate client first Boolean exists = k8sUtils.jobExist(jobName, namespace);
Defensive patterns
Strategy: try-catch
Validate before calling
Objects.requireNonNull(jobName, "jobName required"); Objects.requireNonNull(namespace, "namespace required"); k8sUtils.buildClient(configYaml); // ensure client is initialized
Type guard
boolean clientReady(K8sUtils k) {
return k != null; // plus internal client != null per buildClient success
} Try / catch
try {
exists = k8sUtils.jobExist(jobName, namespace);
} catch (TaskException e) {
log.error("existence check failed for job {} in ns {}", jobName, namespace, e);
throw e;
} Prevention
- Always call buildClient() successfully before any K8sUtils query.
- Verify read permissions (get on batch/jobs) for the worker's service account.
- Distinguish 'not found' (returns false) from 'check failed' (throws) in your logic.
When it happens
Trigger: Calling jobExist(jobName, namespace) when the GET request errors: API server unreachable, invalid kubeconfig/client not built, or RBAC denies 'get' on batch/jobs.
Common situations: Worker's K8s client never initialized via buildClient() (null/blank config); network outage to API server; service account without read access to jobs; checking a job in a namespace the account cannot see.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- fail to create job
- fail to delete job
- fail to register batch job watcher
- namespace %s does not exist in k8s cluster, please create na
- fail to get k8s ApiClient:%s
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/c9084c95f825ad7e.
Report an issue: GitHub.