k3s-io/k3s · error
no snapshots given for removal
Error message
no snapshots given for removal
What it means
The `k3s etcd-snapshot delete` subcommand takes snapshot names as positional arguments. deleteSnapshot checks app.Args(); with zero arguments there is nothing to address the delete operation to, so it fails before contacting etcd. The CLI has no implicit delete-all, by design, to prevent accidental snapshot loss.
Source
Thrown at pkg/cli/etcdsnapshot/etcd_snapshot.go:158
for _, name := range resp.Created {
logrus.Infof("Snapshot %s saved.", name)
}
return nil
}
func Delete(app *cli.Context) error {
if err := cmds.InitLogging(); err != nil {
return err
}
return deleteSnapshot(app, &cmds.ServerConfig)
}
func deleteSnapshot(app *cli.Context, cfg *cmds.Server) error {
snapshots := app.Args()
if snapshots.Len() == 0 {
return errors.New("no snapshots given for removal")
}
sr, info, err := commandSetup(app, cfg)
if err != nil {
return err
}
sr.Operation = etcd.SnapshotOperationDelete
sr.Name = snapshots.Slice()
b, err := json.Marshal(sr)
if err != nil {
return err
}
r, err := info.Post("/db/snapshot", b, clientaccess.WithTimeout(timeout))
if err != nil {
return wrapServerError(err)
}View on GitHub (pinned to 6ba341e396)
Solutions
- Pass one or more snapshot names positionally: k3s etcd-snapshot delete on-demand-12345
- List available names first with k3s etcd-snapshot list to copy the exact name
- To reduce count by policy, use retention/prune options on the server rather than a bare delete
Example fix
# before k3s etcd-snapshot delete # -> no snapshots given for removal # after k3s etcd-snapshot list k3s etcd-snapshot delete etcd-snapshot-1699999999 on-demand-abc123
Defensive patterns
Strategy: validation
Validate before calling
if app.Args().Len() == 0 {
return errors.New("etcd-snapshot delete requires one or more snapshot names; run `k3s etcd-snapshot list` first")
} Type guard
func hasPositionalArgs(args []string) bool { return len(args) > 0 } Prevention
- Wrap delete calls: always `k3s etcd-snapshot list` then pass explicit names
- Guard scripts: fail if the names array is empty instead of calling delete
- Use shellcheck to catch `k3s etcd-snapshot delete $MAYBE_EMPTY` patterns
When it happens
Trigger: Running `k3s etcd-snapshot delete` with no positional names; passing names as a flag (e.g. --name) instead of positional args so Args() stays empty.
Common situations: Scripts ported from other etcd tooling; users expecting `delete` with --prune semantics to need no target; shell quoting that expands an empty variable into no arguments.
Related errors
- invalid output format:
- etcd-snapshot-reconcile-interval must be greater than 0s
- etcd-s3-timeout must be greater than 0s
- --server is required
- service %s is not recognized
AI-assisted analysis of k3s-io/k3s@6ba341e396 (2026-08-15).
Data as JSON: /api/errors/3df0d868f0b8bd59.
Report an issue: GitHub.