{"record":{"id":"bfd514473296374a","repo":"apache/dolphinscheduler","slug":"kubeflow-task-write-yaml-file-failed","errorCode":null,"errorMessage":"Kubeflow task write yaml file failed","messagePattern":"Kubeflow task write yaml file failed","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-task-plugin/dolphinscheduler-task-kubeflow/src/main/java/org/apache/dolphinscheduler/plugin/kubeflow/KubeflowTask.java","lineNumber":148,"sourceCode":"    }\n\n    public void writeFiles() {\n        String yamlContent = kubeflowParameters.getYamlContent();\n        String clusterYAML = kubeflowParameters.getClusterYAML();\n\n        Map<String, Property> paramsMap = taskExecutionContext.getPrepareParamsMap();\n        yamlContent = ParameterUtils.convertParameterPlaceholders(yamlContent, ParameterUtils.convert(paramsMap));\n\n        yamlPath = Paths.get(taskExecutionContext.getExecutePath(), KubeflowHelper.CONSTANTS.YAML_FILE_PATH);\n        clusterYAMLPath =\n                Paths.get(taskExecutionContext.getExecutePath(), KubeflowHelper.CONSTANTS.CLUSTER_CONFIG_PATH);\n\n        log.info(\"Kubeflow task yaml content: \\n{}\", yamlContent);\n        try {\n            Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE);\n            Files.write(clusterYAMLPath, clusterYAML.getBytes(), StandardOpenOption.CREATE);\n        } catch (IOException e) {\n            throw new TaskException(\"Kubeflow task write yaml file failed\", e);\n        }\n    }\n\n    @Override\n    public KubeflowParameters getParameters() {\n        return kubeflowParameters;\n    }\n}\n","sourceCodeStart":130,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-task-plugin/dolphinscheduler-task-kubeflow/src/main/java/org/apache/dolphinscheduler/plugin/kubeflow/KubeflowTask.java#L130-L157","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\ntry {\n    Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE);\n// after\ntry {\n    Files.createDirectories(yamlPath.getParent());\n    Files.write(yamlPath, yamlContent.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);","handlingStrategy":"try-catch","validationCode":"Path dir = yamlPath.getParent();\nif (dir != null && (!java.nio.file.Files.isDirectory(dir) || !dir.toFile().canWrite())) {\n    throw new IllegalStateException(\"cannot write yaml, directory missing/unwritable: \" + dir);\n}","typeGuard":"static boolean canWriteYamlLocation(Path yamlPath) {\n    Path dir = yamlPath.getParent();\n    return dir != null && java.nio.file.Files.isDirectory(dir) && dir.toFile().canWrite();\n}","tryCatchPattern":"try {\n    kubeflowTask.init();\n} catch (TaskException e) {\n    if (e.getMessage().contains(\"write yaml file failed\")) {\n        IOException ioe = (IOException) e.getCause();\n        log.error(\"yaml write failed: {} -> {}\", ioe, ioe.getStackTrace()[0]);\n        // check disk space / permissions on the reported path\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["kubeflow","file-write","io","k8s"],"backgroundTag":"file-write-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}