mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
setup: Perform package operations immediately on trigger
- Operations triggered by FreedomBox service itself such 'apt-get update' and 'apt-get install' don't cause the package operations (post-install and post-update) to get triggered. This is due to recent implementation of a check with the FREEDOMBOX_INVOKED environment variable. So, it fairly safe to attempt these operations immediately as they would have been invoked from outside. - In one case, when unattended-upgrades is triggered it could lead to post-install trigger getting triggered too quickly. But this only leads the operation detecting that apt is busy and performing the long wait immediately after. - In case of distribution upgrade, this could mean simpler reasoning and less wait time. Tests: - When a package is installed, post-dpkg operations are triggered and completed immediately. However, another apt process immediately takes lock, this results in a waiting period. - When a 'apt update' is run, update operations are triggered and completed immediately. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
a67885f793
commit
2ceb80607a
@ -469,12 +469,6 @@ class ForceUpgrader():
|
||||
|
||||
"""
|
||||
for _ in range(self.UPGRADE_ATTEMPTS):
|
||||
logger.info('Waiting for %s seconds before attempting upgrade',
|
||||
self.UPGRADE_ATTEMPT_WAIT_SECONDS)
|
||||
if self._wait_event.wait(self.UPGRADE_ATTEMPT_WAIT_SECONDS):
|
||||
logger.info('Stopping upgrade attempts due to shutdown')
|
||||
return
|
||||
|
||||
try:
|
||||
logger.info('Attempting to perform upgrade')
|
||||
self._attempt_upgrade()
|
||||
@ -489,6 +483,12 @@ class ForceUpgrader():
|
||||
# Assume all other errors are temporary
|
||||
logger.exception('Unknown exception: %s', exception)
|
||||
|
||||
logger.info('Waiting for %s seconds before attempting upgrade',
|
||||
self.UPGRADE_ATTEMPT_WAIT_SECONDS)
|
||||
if self._wait_event.wait(self.UPGRADE_ATTEMPT_WAIT_SECONDS):
|
||||
logger.info('Stopping upgrade attempts due to shutdown')
|
||||
return
|
||||
|
||||
logger.info('Giving up on upgrade after too many retries')
|
||||
|
||||
def shutdown(self):
|
||||
@ -748,14 +748,6 @@ class DpkgHandler:
|
||||
This method is guaranteed to not to run more than once simultaneously.
|
||||
"""
|
||||
for _ in range(self.HANDLE_ATTEMPTS):
|
||||
logger.info(
|
||||
'Waiting for %s seconds before attempting post-dpkg '
|
||||
'operations', self.HANDLE_ATTEMPT_WAIT_SECONDS)
|
||||
if self._wait_event.wait(self.HANDLE_ATTEMPT_WAIT_SECONDS):
|
||||
logger.info(
|
||||
'Stopping post-dpkg operation attempts due to shutdown')
|
||||
return
|
||||
|
||||
try:
|
||||
logger.info('Attempting to perform post-dpkg operations')
|
||||
self._attempt_post_invoke()
|
||||
@ -771,6 +763,14 @@ class DpkgHandler:
|
||||
# Assume all other errors are temporary
|
||||
logger.exception('Unknown exception: %s', exception)
|
||||
|
||||
logger.info(
|
||||
'Waiting for %s seconds before attempting post-dpkg '
|
||||
'operations', self.HANDLE_ATTEMPT_WAIT_SECONDS)
|
||||
if self._wait_event.wait(self.HANDLE_ATTEMPT_WAIT_SECONDS):
|
||||
logger.info(
|
||||
'Stopping post-dpkg operation attempts due to shutdown')
|
||||
return
|
||||
|
||||
logger.info('Giving up on post-dpkg operations after too many retries')
|
||||
|
||||
def _attempt_post_invoke(self) -> None:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user