Skip to content

Commit 36852ce

Browse files
tonistiigijedevc
authored andcommitted
prune: update free-space filter when no max-space set
When free-space filter is set without max-space or reserved-space filter, the behaviour is that if the filter matches some records then these records would be pruned, but if it doesn't match any (there are more free space than filter sets already) then the keepBytes would be left to 0, resulting records to be deleted as if no storage constraint was set at all. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 9c8ee9e commit 36852ce

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cache/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,9 @@ func calculateKeepBytes(totalSize int64, dstat disk.DiskStat, opt client.PruneIn
10921092
} else {
10931093
keepBytes = min(keepBytes, totalSize-excess)
10941094
}
1095+
} else if opt.MinFreeSpace != 0 && keepBytes == 0 {
1096+
// if only minFreeSpace is set and it doesn't match then we don't delete anything
1097+
keepBytes = totalSize
10951098
}
10961099

10971100
// but make sure we don't take the total below the reserved space

0 commit comments

Comments
 (0)