From 44b4c38d8afbeed0dd64309442d35c9292a45592 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 3 Apr 2025 14:17:52 -0700 Subject: [PATCH] upgrades: Use special desc. for snapshots take before dist upgrade - This will help identify these snapshots more easily in case a revert it needed. Tests: - Start a distribution upgrade. Notice that the snapshot taken has special description that it was taken before a distribution upgrade. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/upgrades/distupgrade.py | 6 ++---- plinth/modules/upgrades/tests/test_distupgrade.py | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/plinth/modules/upgrades/distupgrade.py b/plinth/modules/upgrades/distupgrade.py index 576a9213a..50b3db63b 100644 --- a/plinth/modules/upgrades/distupgrade.py +++ b/plinth/modules/upgrades/distupgrade.py @@ -237,10 +237,8 @@ def _snapshot_run_and_disable() -> Generator[None, None, None]: reenable = False try: logger.info('Taking a snapshot before dist upgrade...') - subprocess.run([ - '/usr/share/plinth/actions/actions', 'snapshot', 'create', - '--no-args' - ], check=True) + command = ['snapper', 'create', '--description', 'before dist-upgrade'] + subprocess.run(command, check=True) aug = snapshot_module.load_augeas() if snapshot_module.is_apt_snapshots_enabled(aug): logger.info('Disabling apt snapshots during dist upgrade...') diff --git a/plinth/modules/upgrades/tests/test_distupgrade.py b/plinth/modules/upgrades/tests/test_distupgrade.py index ed3ed8934..57aa8754d 100644 --- a/plinth/modules/upgrades/tests/test_distupgrade.py +++ b/plinth/modules/upgrades/tests/test_distupgrade.py @@ -248,10 +248,8 @@ def test_snapshot_run_and_disable(is_supported, is_apt_snapshots_enabled, run): is_apt_snapshots_enabled.return_value = False with distupgrade._snapshot_run_and_disable(): assert run.call_args_list == [ - call([ - '/usr/share/plinth/actions/actions', 'snapshot', 'create', - '--no-args' - ], check=True) + call(['snapper', 'create', '--description', 'before dist-upgrade'], + check=True) ] run.reset_mock() @@ -261,10 +259,8 @@ def test_snapshot_run_and_disable(is_supported, is_apt_snapshots_enabled, run): is_apt_snapshots_enabled.return_value = True with distupgrade._snapshot_run_and_disable(): assert run.call_args_list == [ - call([ - '/usr/share/plinth/actions/actions', 'snapshot', 'create', - '--no-args' - ], check=True), + call(['snapper', 'create', '--description', 'before dist-upgrade'], + check=True), call([ '/usr/share/plinth/actions/actions', 'snapshot', 'disable_apt_snapshot'