From 0f484d7eaadba22652dd81d45a421961ec16486d Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 2 Feb 2023 12:58:33 -0800 Subject: [PATCH] snapshot: Fix issue with snapshot rollbacks Closes: #2144. - '--ambit' seems to a required argument if there is no default subvolume set on the filesystem. Add it to prevent error during rollback. - Description is not a required option for rollback (anymore?) and default descriptions for the two snapshots are more descriptive. Tests: - On a fresh vagrant machine, run snapshot rollback with the patch. It fails. With the patch, rollback succeeds. - The description created for the rollback is the default one 'rollback backup' and 'writable copy of #x'. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/snapshot/privileged.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plinth/modules/snapshot/privileged.py b/plinth/modules/snapshot/privileged.py index f0d18e24a..6facfd790 100644 --- a/plinth/modules/snapshot/privileged.py +++ b/plinth/modules/snapshot/privileged.py @@ -251,7 +251,12 @@ def kill_daemon(): @privileged def rollback(number: str): """Rollback to snapshot.""" - command = [ - 'snapper', 'rollback', '--description', 'created by rollback', number - ] + # "ambit" is not very well documented by snapper. Default ambit is "auto" + # which errors out if default subvolume is not yet set on the filesystem. + # If set, then it acts as "transactional" ambit if the default snapshot is + # readonly, otherwise it acts as "classic". The "classic" behavior is the + # one described snapper(8) man page for rollback behavior. The classic + # behavior when a snapshot number to rollback to is provided is the + # behavior that we desire. + command = ['snapper', '--ambit', 'classic', 'rollback', number] subprocess.run(command, check=True)