-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snapper: Set userdata to important=yes #111
Comments
Oh and apparently openSUSE changes the default limits:
So they actually do keep more important snapshots than normal ones, when constrained by quotas. This range syntax This of course is the wrong place to discuss possible changes to the snapper default config template, but I thought it might be relevant to the consideration of whether to mark DNF snapshots |
Actually looking at the sources for the zypper snapper plugin, it seems they define importance in a configuration file based on pattern matching against affected packages: <?xml version="1.0" encoding="utf-8"?>
<snapper-zypp-plugin-conf>
<!-- List of solvables. If the zypp commit transaction includes any solvable
listed below, snapper will create pre and post snapshots. The match
attribute defines whether the pattern is a Unix shell-style wildcard
("w") or a Python regular expression ("re"). If any of the matching
solvables is marked as important, the snapshots are also marked as
important. -->
<solvables>
<solvable match="w" important="true">kernel-*</solvable>
<solvable match="w" important="true">dracut</solvable>
<solvable match="w" important="true">glibc</solvable>
<solvable match="w" important="true">systemd*</solvable>
<solvable match="w" important="true">udev</solvable>
<solvable match="w">*</solvable>
</solvables>
</snapper-zypp-plugin-conf> When I tried a Maybe we don't need all of this feature copied, but it might be nice to have some distinction of importance between snapshots. |
How about an [kernel-*]
important=yes
[dracut]
important=yes
[glibc]
important=yes
[systemd*]
important=yes
[udev]
important=yes
[*]
important=no I could probably code this up myself, but I don't really know how you're supposed to actually replace the system dnf plugin code and test it... Deleting the Something like this should do it, but I haven't tested it: import fnmatch
def set_userdata(self):
self.userdata = {}
conf = Snapper.read_config(self.base.conf)
pkgs = self.base.transaction.install_set | self.base.transaction.remove_set
for section in conf.sections():
for pkg in pkgs:
if fnmatch.filter(pkg.provides, section):
self.userdata = dict(conf.items(section, raw=True))
return You'd then call this in |
Alternatively |
To mimic the libzypp behavior you also need to make the snapshots conditional on the configuration matching. import fnmatch
def __init__(self, base, cli):
self.base = base
self.description = " ".join(sys.argv)
self.userdata = {}
[...]
def pre_transaction(self):
if not len(self.base.transaction):
return
conf = Snapper.read_config(self.base.conf)
pkgs = self.base.transaction.install_set | self.base.transaction.remove_set
for section in conf.sections():
if fnmatch.filter((pkg.name for pkg in pkgs), section):
self.userdata = dict(conf.items(section, raw=True))
break
else:
return
[...] |
...Actually filter will test all packages even if the first one matches, so back to nested loops: for section in conf.sections():
for pkg in pkgs:
if fnmatch.fnmatch(pkg.name, section):
self.userdata = dict(conf.items(section, raw=True))
break
else:
continue
break
else:
return
def set_userdata(self):
conf = Snapper.read_config(self.base.conf)
pkgs = self.base.transaction.install_set | self.base.transaction.remove_set
for section in conf.sections():
for pkg in pkgs:
if fnmatch.fnmatch(pkg.name, section):
self.userdata = dict(conf.items(section, raw=True))
return True
return False
def pre_transaction(self):
if not self.set_userdata():
return
[...] We can skip the |
Hello, dnf team is doing a review of old and forgotten issues. Apologies for the enormous delay. We would like to take a look at your contribution. Are you still interested in this fix?
With that said, we are willing to provide help to accept contributions for this plugin. |
With snapper you can set
--userdata important=yes
when creating a snapshot which will make automatic cleanups more conservative by merit of supposedly being fewer and being counted separately. By default:meaning that for snapshots marked for the "number" cleanup algorithm, it will keep the last 50 normal snapshots and the last 10 important snapshots. So even if the 10th oldest important snapshot is older than the 50th oldest snapshot, it gets preserved.
On openSUSE,
zypper
transactions are marked important, butsnapper-boot.timer
snapshots and YaST commands (which create pre-post snapshots) are not. It would seem prudent to mimic them in this, and mark DNF snapshots important. Even if we don't have YaST, we do havesnapper-boot.timer
and we do havesnapper create --command
which can wrap any command in a pre-post snapshot. It would be useful for DNF upgrades to be preserved more conservatively than those uses.I'm not clear on what happens to "important" snapshots that are older than
NUMBER_LIMIT_IMPORTANT
but younger thanNUMBER_LIMIT
; do they get deleted before unimportant snapshots or do they get demoted to unimportant and kept until that limit is reached? Either way the idea seems to be that important snapshots are much rarer, and so take longer to reach the limits. That's understandable on openSUSE which wraps every YaST command in a pre-post snapshot, but it's less likely to be the case on a Fedora system unless you usesnapper create --cleanup-algorithm number --command {cmd}
liberally. But only by marking DNF snapshots important do we enable this use case, so it could be worth it. You can also adjustNUMBER_LIMIT_IMPORTANT
if you find that only keeping 10 as opposed to 50 DNF snapshots isn't enough for you. The main point is that they're kept up to that limit regardless of how many other "number" snapshots you create for other purposes.The text was updated successfully, but these errors were encountered: