From 70ba4d6b88e9f984f210d0c4e3792b0f771c9432 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 30 Jan 2021 10:00:49 -0500 Subject: [PATCH] upgrades: Add notifications for dist upgrade Notification for dist upgrade started, or not started due to lack of free space. Currently, these notifications only appear once. Tests: - Checked each notification appears. - Notification does not appear again after being dismissed. Signed-off-by: James Valleroy Reviewed-by: Veiko Aasa --- plinth/modules/upgrades/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plinth/modules/upgrades/__init__.py b/plinth/modules/upgrades/__init__.py index b67fa678d..097a2b907 100644 --- a/plinth/modules/upgrades/__init__.py +++ b/plinth/modules/upgrades/__init__.py @@ -185,6 +185,7 @@ def setup_repositories(_): def check_dist_upgrade(_): """Check for upgrade to new stable release.""" + from plinth.notification import Notification if is_dist_upgrade_enabled(): output = actions.superuser_run('upgrades', ['start-dist-upgrade']) result = json.loads(output) @@ -206,8 +207,29 @@ def check_dist_upgrade(_): logger.info('Skip dist upgrade: --test is not set.') elif 'not-enough-free-space' in reason: logger.warning('Skip dist upgrade: Not enough free space in /.') + title = ugettext_noop('Could not start distribution update') + message = ugettext_noop( + 'There is not enough free space in the root partition to ' + 'start the distribution update. Please ensure at least 5 GB, ' + 'and at least 10% of the total space, is free. Distribution ' + 'update will be retried after 24 hours, if enabled.') + Notification.update_or_create( + id='upgrades-dist-upgrade-free-space', app_id='upgrades', + severity='warning', title=title, message=message, actions=[{ + 'type': 'dismiss' + }], group='admin') elif 'started-dist-upgrade' in reason: logger.info('Started dist upgrade.') + title = ugettext_noop('Distribution update started') + message = ugettext_noop( + 'Started update to next stable release. This may take a long ' + 'time to complete.') + Notification.update_or_create(id='upgrades-dist-upgrade-started', + app_id='upgrades', severity='info', + title=title, message=message, + actions=[{ + 'type': 'dismiss' + }], group='admin') else: logger.warning('Unhandled result of start-dist-upgrade: %s, %s', dist_upgrade_started, reason)