zfs-snap-manager
zfs-snap-manager copied to clipboard
allow more lenient schemas
50d1y
is currently not a valid schema. One also has to define zero-sized buckets (50d0w0m1y
) for the tool to work in the current state.
Hey, I hope my feature request is meaning the same like the one from @SlothOfAnarchy.
I ran into the issue that one dataset never got a snapshot. After playing around with it, I've figured out that I've configured the schema
value wrong since almost day one.
The snapshot was never done since for that dataset, I've just configured 7d
as value of schema
.
My other configurations where partly working (but working good enough) so that a snapshot was created but none of them where deleted. After configuring the schema
right like 7d0w0m0y
, everything was working as expected.
After this explenation, finally the feature request. For each value part of the schema
, could you check if it exists and if not replace it with a default value of 0
?
I bet my feature request solves half of @SlothOfAnarchy feature requests problem. That is the reason I've put it in here.
Thanks for your work so far. Your zfs-snap-manager
really ease up my life :).
edit
After searching inside the manager.py for schema
, I guess I found the right place in the clean.py.
So taking my feature request into account, we have to either add logic after the line if not match:
or replace the regular expression fully.
As a clunky draft, following my additional code after the if not match
line.
I am not a python developer so I used my know concepts and write it as easy as possible.
#example schema
schema = "50d1y"
#define default values for each possible variable
valueOfDay = 0
valueOfWeek = 0
valueOfMonth = 0
valueOfYear = 0
#the idea is to iterate over the whole schema and collect values (integers) until
# we find a fitting and expected character
currentValue = ""
for character in schema:
if character == 'd':
#we found an expected character so we overwrite the value with the collected
valueOfDay = currentValue
#reset/clean currentValue since we found it
currentValue = ""
elif character == 'w':
valueOfWeek = currentValue
currentValue = ""
elif character == 'm':
valueOfMonth = currentValue
currentValue = ""
elif character == 'y':
valueOfYear = currentValue
currentValue = ""
else:
#one big issue, if the schema contains unexpected characters like `z`, this would end up in the currentValue
# we have to add a typecheck to only concatinate integers to a big currentValue variable
currentValue = str(currentValue) + str(character)
#create "match hash table" but this is not a match object
match = {"days": valueOfDay, "weeks": valueOfWeek, "months": valueOfMonth, "years": valueOfYear}
#output content
#print(match)
I'm closing this issue as I unfortunately don't have the time anymore to maintain ZFS Snapshot Manager. I would like to point you towards the awesome tool zrepl which has nearly all of ZFS Snapshot Manager's features and much more.
In any case, thanks for being a part of this community.