add gc greedy
This commit is contained in:
parent
5dda6562a6
commit
ad19226d02
1 changed files with 35 additions and 12 deletions
23
btv
23
btv
|
@ -9,6 +9,7 @@ import json
|
|||
import os
|
||||
import shlex
|
||||
import sys
|
||||
import time
|
||||
|
||||
CONFIG = "/etc/btv/config.ini"
|
||||
LOCKFILE = "/run/lock/btv/serialization.lock"
|
||||
|
@ -487,8 +488,27 @@ def do_stream(args):
|
|||
def do_gc(args=None):
|
||||
"""
|
||||
Drops old snapshots.
|
||||
|
||||
If the only arg is "greedy", drops ALL snapshots except the youngest
|
||||
Rank 2.
|
||||
"""
|
||||
|
||||
if args and "greedy" in args:
|
||||
newest = list_snapshots(2)[-1]
|
||||
|
||||
if newest:
|
||||
print(">>> Dropping all snapshots except the newest Rank 2 in 5 s...")
|
||||
time.sleep(5)
|
||||
|
||||
for snap in list_snapshots():
|
||||
if snap.name != newest.name:
|
||||
snap.drop()
|
||||
|
||||
else:
|
||||
print("!!! no Rank 2 snapshot exists")
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
counts = [0, 0, 0] # Rank 0, 1, 2
|
||||
limits = [
|
||||
cfg.getint("gc", "rank_0_count"),
|
||||
|
@ -537,6 +557,9 @@ Verbs:
|
|||
|
||||
gc
|
||||
Drops old local snapshots based on garbage collector settings.
|
||||
|
||||
gc greedy
|
||||
Drop ALL snapshots except the newest Rank 2.
|
||||
""".format(cmd=sys.argv[0]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue