apache/dolphinscheduler · error · TaskException
Kubeflow task write yaml file failed
Error message
Kubeflow task write yaml file failed
What it means
KubeflowTask.writeFiles writes the task's resource YAML and the cluster YAML to local files so kubectl can apply them; an IOException during Files.write is wrapped in TaskException 'Kubeflow task write yaml file failed'. Called from init(), so the task fails immediately before any cluster interaction.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-kubeflow/src/main/java/org/apache/dolphinscheduler/plugin/kubeflow/KubeflowTask.java:148
}
public void writeFiles() {
String yamlContent = kubeflowParameters.getYamlContent();
String clusterYAML = kubeflowParameters.getClusterYAML();
Map<String, Property> paramsMap = taskExecutionContext.getPrepareParamsMap();
yamlContent = ParameterUtils.convertParameterPlaceholders(yamlContent, ParameterUtils.convert(paramsMap));
yamlPath = Paths.get(taskExecutionContext.getExecutePath(), KubeflowHelper.CONSTANTS.YAML_FILE_PATH);
clusterYAMLPath =
Paths.get(taskExecutionContext.getExecutePath(), KubeflowHelper.CONSTANTS.CLUSTER_CONFIG_PATH);
log.info("Kubeflow task yaml content: \n{}", yamlContent);
try {
Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE);
Files.write(clusterYAMLPath, clusterYAML.getBytes(), StandardOpenOption.CREATE);
} catch (IOException e) {
throw new TaskException("Kubeflow task write yaml file failed", e);
}
}
@Override
public KubeflowParameters getParameters() {
return kubeflowParameters;
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Check the wrapped IOException for the exact path and cause (NoSpaceLeft, AccessDenied, NoSuchFile).
- Ensure the task working directory exists and is writable by the worker user; create missing parent directories beforehand.
- Free disk space or fix volume mounts if the filesystem is full or read-only.
- Verify container/worker security context allows file creation in the execution path.
Example fix
// before
try {
Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE);
// after
try {
Files.createDirectories(yamlPath.getParent());
Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); Defensive patterns
Strategy: try-catch
Validate before calling
Path dir = yamlPath.getParent();
if (dir != null && (!java.nio.file.Files.isDirectory(dir) || !dir.toFile().canWrite())) {
throw new IllegalStateException("cannot write yaml, directory missing/unwritable: " + dir);
} Type guard
static boolean canWriteYamlLocation(Path yamlPath) {
Path dir = yamlPath.getParent();
return dir != null && java.nio.file.Files.isDirectory(dir) && dir.toFile().canWrite();
} Try / catch
try {
kubeflowTask.init();
} catch (TaskException e) {
if (e.getMessage().contains("write yaml file failed")) {
IOException ioe = (IOException) e.getCause();
log.error("yaml write failed: {} -> {}", ioe, ioe.getStackTrace()[0]);
// check disk space / permissions on the reported path
}
throw e;
} Prevention
- Ensure the task execution working directory exists and is writable before scheduling.
- Monitor worker disk usage and enforce volume quotas.
- Use writable volumes in containerized workers; avoid read-only root filesystems.
- Create parent directories (Files.createDirectories) before writing generated YAML.
When it happens
Trigger: writeFiles() runs and Files.write(yamlPath/clusterYAMLPath, ...) throws IOException — parent directory missing/unwritable, disk full, or filesystem permission denied (StandardOpenOption.CREATE only creates the file, not directories).
Common situations: Worker task execution directory does not exist or was cleaned, read-only container filesystem, quota/disk-full on worker node, or permission mismatch between worker user and task working directory.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Kubeflow task params is not valid
- Kubeflow task submit command failed
- generate spark sql script error
- Create xlsx directory error
- generate excel error
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/bfd514473296374a.
Report an issue: GitHub.