summaryrefslogtreecommitdiff
path: root/internal/zfsutil
diff options
context:
space:
mode:
Diffstat (limited to 'internal/zfsutil')
-rw-r--r--internal/zfsutil/zfsutil.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/zfsutil/zfsutil.go b/internal/zfsutil/zfsutil.go
index 8f1b0e2..918289c 100644
--- a/internal/zfsutil/zfsutil.go
+++ b/internal/zfsutil/zfsutil.go
@@ -33,6 +33,14 @@ func Rollback(ctx context.Context, out io.Writer, dataset, tag string) error {
return sh.Run(ctx, out, "", "zfs", "rollback", "-r", snapRef(dataset, tag))
}
+// DestroySnapshot removes a snapshot that was never needed as a rollback
+// target - e.g. one taken right before an apply step that failed before
+// anything actually changed. Left behind, it collides with the same tag on
+// the next retry.
+func DestroySnapshot(ctx context.Context, out io.Writer, dataset, tag string) error {
+ return sh.Run(ctx, out, "", "zfs", "destroy", snapRef(dataset, tag))
+}
+
// Snapshots lists snapshot names (without the dataset@ prefix), newest last.
func Snapshots(ctx context.Context, dataset string) ([]string, error) {
raw, err := sh.Output(ctx, "", "zfs", "list", "-H", "-t", "snapshot", "-o", "name", "-s", "creation", "-r", dataset)