kubernetes/kops · error
reading from stdin: %v
Error message
reading from stdin: %v
What it means
Returned by `kops delete -f -` when `ConsumeStdin` fails while reading the manifests from standard input. kOps reads the full stdin stream as the resource spec(s) to delete; an error reading the stream (e.g. closed/broken pipe) aborts the delete with this wrapper.
Source
Thrown at cmd/kops/delete.go:90
cmd.AddCommand(NewCmdDeleteInstance(f, out))
cmd.AddCommand(NewCmdDeleteInstanceGroup(f, out))
cmd.AddCommand(NewCmdDeleteSecret(f, out))
cmd.AddCommand(NewCmdDeleteSSHPublicKey(f, out))
return cmd
}
func RunDelete(ctx context.Context, factory *util.Factory, out io.Writer, d *DeleteOptions) error {
// We could have more than one cluster in a manifest so we are using a set
deletedClusters := sets.NewString()
for _, f := range d.Filenames {
var contents []byte
var err error
if f == "-" {
contents, err = ConsumeStdin()
if err != nil {
return fmt.Errorf("reading from stdin: %v", err)
}
} else {
contents, err = factory.VFSContext().ReadFile(f)
if err != nil {
return fmt.Errorf("reading file %q: %v", f, err)
}
}
sections := text.SplitContentToSections(contents)
for _, section := range sections {
o, gvk, err := kopscodecs.Decode(section, nil)
if err != nil {
return fmt.Errorf("parsing file %q: %v", f, err)
}
switch v := o.(type) {
case *kopsapi.Cluster:
options := &DeleteClusterOptions{View on GitHub (pinned to 4c8573c808)
Solutions
- Ensure something actually pipes data in: `cat resources.yaml | kops delete -f -`.
- Check the upstream command in the pipeline succeeded before kOps consumed stdin.
- If you meant to read a file, pass the filename instead of `-`.
Example fix
// before (no stdin in CI) kops delete -f - // after kops delete -f resources.yaml
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure stdin has data when using '-'
const stdinData = fs.readFileSync(0, 'utf8'); // throws immediately if stdin empty/closed
if (!stdinData.trim()) throw new Error('No manifest provided on stdin'); Try / catch
try {
runKops(['delete', '-f', '-']);
} catch (e) {
if (/reading from stdin/.test(e.message)) {
console.error('stdin read failed; pipe a manifest in or use -f <file>.');
}
throw e;
} Prevention
- Prefer file-based -f paths in CI (no stdin allocated)
- Check pipeline upstream exit codes
- Never use '-' interactively without piping data
When it happens
Trigger: Running `kops delete -f -` where stdin is closed, is not piped at all, or the producer process terminates mid-stream (broken pipe / EOF condition surfaced as an error).
Common situations: Shell pipelines like `kops get cluster -o yaml | kops delete -f -` where the upstream command fails; interactive shells with no stdin attached; CI runners without stdin allocated when `-` is accidentally used instead of a filename.
Related errors
- reading file %q: %v
- must specify %q label with cluster name to create instanceGr
- error querying cluster %q: %v
- cluster %q not found
- instanceGroup %q already exists
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/9b6b75b93fbd0627.
Report an issue: GitHub.