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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-04-03 14:17:52 -07:00 committed by James Valleroy
parent 30b057e7ee
commit 44b4c38d8a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 6 additions and 12 deletions

View File

@ -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...')

View File

@ -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'