{"record":{"id":"233fa654223b8f7e","repo":"kubernetes/kops","slug":"error-writing-to-output-v-233fa6","errorCode":null,"errorMessage":"error writing to output: %v","messagePattern":"error writing to output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/kops/create_cluster.go","lineNumber":922,"sourceCode":"\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\t\t\tfmt.Fprintf(&sb, \"Cluster configuration has been created.\\n\")\n\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\t\t\tfmt.Fprintf(&sb, \"Suggestions:\\n\")\n\t\t\tfmt.Fprintf(&sb, \" * list clusters with: kops get cluster\\n\")\n\t\t\tfmt.Fprintf(&sb, \" * edit this cluster with: kops edit cluster %s\\n\", cluster.Name)\n\t\t\tif len(nodes) > 0 {\n\t\t\t\tfmt.Fprintf(&sb, \" * edit your node instance group: kops edit ig --name=%s %s\\n\", cluster.Name, nodes[0].ObjectMeta.Name)\n\t\t\t}\n\t\t\tif len(controlPlanes) > 0 {\n\t\t\t\tfmt.Fprintf(&sb, \" * edit your control-plane instance group: kops edit ig --name=%s %s\\n\", cluster.Name, controlPlanes[0].ObjectMeta.Name)\n\t\t\t}\n\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\t\t\tfmt.Fprintf(&sb, \"Finally configure your cluster with: kops update cluster --name %s --yes --admin\\n\", cluster.Name)\n\t\t\tfmt.Fprintf(&sb, \"\\n\")\n\n\t\t\t_, err := out.Write(sb.Bytes())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error writing to output: %v\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// checkProjectFlag rejects an explicitly empty --project flag. An empty value usually comes from\n// an unset environment variable (e.g. --project=$PROJECT); silently accepting it would fall back\n// to the gcloud default project, which may not be the intended one.\nfunc checkProjectFlag(flagSet bool, project string) error {\n\tif flagSet && project == \"\" {\n\t\treturn fmt.Errorf(\"--project cannot be empty; specify a project or omit the flag to use the gcloud default project\")\n\t}\n\treturn nil\n}\n\n// parseCloudLabels takes a CSV list of key=value records and parses them into a map. Nested '='s are supported via","sourceCodeStart":904,"sourceCodeEnd":940,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L904-L940","documentation":"At the end of a successful create, kops writes a next-steps message (suggesting `kops update cluster --name <name> --yes --admin`) to the output writer. This error means the Write call on that writer failed. It occurs after the cluster config and SSH keys were already persisted, so the cluster exists but the instructions were never displayed.","triggerScenarios":"`kops create cluster` completing successfully but out.Write fails — e.g. stdout is a closed pipe (EPIPE), full disk on a redirected file, or the stream was closed by a wrapper program.","commonSituations":"`kops create cluster | head -1` causing SIGPIPE in scripts; stdout redirected to a file on a full filesystem; output stream closed by a CI runner or wrapper.","solutions":["Re-run with a plain terminal or a healthy redirect target.","Check disk space if output was redirected to a file.","The cluster is likely already created — run `kops get clusters` to confirm, then proceed with `kops update cluster --name <name> --yes --admin`.","Avoid piping kops output into commands that exit early (write to a file instead)."],"exampleFix":"// before\nkops create cluster ... | head -1   # EPIPE on write\n// after\nkops create cluster ... > create-output.txt","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runCreateCluster(...); err != nil {\n\tif strings.Contains(err.Error(), \"error writing to output\") {\n\t\t// cluster is likely created; verify with kops get clusters and print next steps yourself\n\t}\n\treturn err\n}","preventionTips":["Do not pipe kops output into commands that exit early (head, grep -m1).","Write output to a file instead of a pipe in automation.","Check disk space on hosts running kops.","Treat this error as post-success: the cluster config is already persisted."],"tags":["cli","stdout","broken-pipe"],"backgroundTag":"stdout-write-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}