{"record":{"id":"1c02414da0e37946","repo":"argoproj/argo-workflows","slug":"failed-to-write-template-w","errorCode":null,"errorMessage":"failed to write template: %w","messagePattern":"failed to write template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argoexec/commands/supervisor.go","lineNumber":144,"sourceCode":"\n// supervisorPreMain runs the pre-main phase: template write, script staging,\n// and input artifact download (non-plugin and per-plugin in parallel).\nfunc supervisorPreMain(ctx context.Context, wfExecutor *wfexecutor.WorkflowExecutor) error {\n\t// Zero umask so files/dirs created here are accessible to main when it\n\t// runs as a different uid. The legacy init container does the same.\n\tosspecific.AllowGrantingAccessToEveryone()\n\n\t// A stale marker from a prior attempt needs no explicit cleanup: the\n\t// heartbeat's initial RUNNING write (startStatusHeartbeat, before we get\n\t// here) has already overwritten it with a fresh mtime.\n\treturn runSupervisorPreMain(ctx, wfExecutor, inputArtifactPluginNames())\n}\n\n// runSupervisorPreMain is the testable core of supervisorPreMain. Takes\n// the plugin name list explicitly so tests don't have to mutate env vars.\nfunc runSupervisorPreMain(ctx context.Context, stages preMainStages, pluginNames []wfv1.ArtifactPluginName) error {\n\tif err := stages.WriteTemplate(); err != nil {\n\t\treturn fmt.Errorf(\"failed to write template: %w\", err)\n\t}\n\tif err := stages.StageFiles(ctx); err != nil {\n\t\treturn fmt.Errorf(\"failed to stage files: %w\", err)\n\t}\n\n\tg, gctx := errgroup.WithContext(ctx)\n\tg.Go(func() error {\n\t\tif err := stages.LoadArtifactsWithoutPlugins(gctx); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to load non-plugin input artifacts: %w\", err)\n\t\t}\n\t\treturn nil\n\t})\n\tfor _, name := range pluginNames {\n\t\tg.Go(func() error {\n\t\t\tif err := stages.LoadArtifactsFromPlugin(gctx, name); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to load input artifacts from plugin %q: %w\", name, err)\n\t\t\t}\n\t\t\treturn nil","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argoexec/commands/supervisor.go#L126-L162","documentation":"runSupervisorPreMain (the testable core of the supervisor's pre-main phase) calls the WriteTemplate stage first; if it fails the error is wrapped as \"failed to write template\". WriteTemplate persists the workflow template to /var/run/argo/template so the main container can read it, so failure means the supervisor could not set up the contract shared with the main container and pre-main short-circuits.","triggerScenarios":"supervisorPreMain → runSupervisorPreMain where the WriteTemplate stage returns an error — unwritable /var/run/argo, disk full, or marshaling problems with the template payload.","commonSituations":"Missing or read-only shared volume mount at /var/run/argo in init-less workflow pods; ephemeral storage exhausted; SELinux/AppArmor blocking writes to the emptyDir.","solutions":["Check the wrapped cause for the underlying filesystem error (EACCES/ENOSPC/ENOENT)","Ensure /var/run/argo exists and is writable by the argoexec user in the pod","Verify the shared volume is defined for both supervisor and main containers","Check node DiskPressure conditions and pod ephemeral-storage limits"],"exampleFix":"// before: no volume mount in the pod spec\ntemplates:\n  - name: main\n    container: ...\n// after: ensure the shared argo volume is mounted\nspec:\n  volumes:\n    - name: var-run-argo\n      emptyDir: {}\n  containers:\n    - name: main\n      volumeMounts:\n        - name: var-run-argo\n          mountPath: /var/run/argo","handlingStrategy":"try-catch","validationCode":"// inside the pod, before main runs:\n// test -w /var/run/argo && df -h /var/run/argo","typeGuard":null,"tryCatchPattern":"if err := stages.WriteTemplate(); err != nil {\n    return fmt.Errorf(\"failed to write template: %w\", err) // inspect cause for fs errors\n}\n// caller: errors.Is(err, syscall.ENOSPC) / errors.As(err, *fs.PathError)","preventionTips":["Always mount an emptyDir at /var/run/argo shared by supervisor and main","Set fsGroup/securityContext so argoexec can write the mount","Monitor ephemeral storage on nodes running workflows","Keep a smoke-test workflow exercising the init-less path in CI"],"tags":["go","argo-executor","supervisor","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}