@@ -578,7 +578,7 @@ func (m *Manager) checkDependentClones(snapshotName string) (string, error) {
578578}
579579
580580// CleanupSnapshots destroys old snapshots considering retention limit and related clones.
581- func (m * Manager ) CleanupSnapshots (retentionLimit int ) ([]string , error ) {
581+ func (m * Manager ) CleanupSnapshots (retentionLimit int , mode models. RetrievalMode ) ([]string , error ) {
582582 clonesCmd := fmt .Sprintf ("zfs list -S clones -o name,origin -H -r %s" , m .config .Pool .Name )
583583
584584 clonesOutput , err := m .runner .Run (clonesCmd )
@@ -588,10 +588,16 @@ func (m *Manager) CleanupSnapshots(retentionLimit int) ([]string, error) {
588588
589589 busySnapshots := m .getBusySnapshotList (clonesOutput )
590590
591+ modeFilter := ""
592+
593+ if mode == models .Physical {
594+ modeFilter = "| grep _pre$"
595+ }
596+
591597 cleanupCmd := fmt .Sprintf (
592- "zfs list -t snapshot -H -o name -s %s -s creation -r %s | grep -v clone | grep _pre$ | head -n -%d %s" +
598+ "zfs list -t snapshot -H -o name -s %s -s creation -r %s | grep -v clone %s | head -n -%d %s" +
593599 "| xargs -n1 --no-run-if-empty zfs destroy -R " ,
594- dataStateAtLabel , m .config .Pool .Name , retentionLimit , excludeBusySnapshots (busySnapshots ))
600+ dataStateAtLabel , m .config .Pool .Name , modeFilter , retentionLimit , excludeBusySnapshots (busySnapshots ))
595601
596602 out , err := m .runner .Run (cleanupCmd )
597603 if err != nil {
@@ -892,7 +898,9 @@ func (m *Manager) SnapshotList() []resources.Snapshot {
892898// RefreshSnapshotList updates the list of snapshots.
893899func (m * Manager ) RefreshSnapshotList () {
894900 snapshots , err := m .getSnapshots ()
895- if err != nil {
901+
902+ var emptyPoolError * EmptyPoolError
903+ if err != nil && ! errors .As (err , & emptyPoolError ) {
896904 log .Err ("failed to refresh snapshot list: " , err )
897905 return
898906 }
0 commit comments