Implement automatic upgrade of Plinth modules
Created by: SunilMohanAdapa
Currently, when a new version of module code arrives with a Plinth upgrade, the module is not upgraded automatically. Debian software packages required for the modules are automatically upgraded because of unattended-upgrades
and its Plinth integration. This means that users will have to click on a module and manually trigger an upgrade to newer version. This was never the intention of the original design and we intended to implement automatic upgrade. This task is to implement automatic upgrade.
Plinth module code is updated only when Plinth code is updated and that happens when newer version of Plinth is installed by unattended-upgrades
. Hence, we can start the process of upgrading the modules as soon as Plinth is restarted.
However, module upgrades may involve additional package installation. When unattended-upgrades
has upgraded the Plinth code and restarted it as a consequence, we can't start the upgrade process immediately since unattended-upgrades might be upgrading other packages and the package manager will be busy.
The following approach might work out:
- Start a background thread for upgrading Plinth modules as soon as Plinth is started.
- In the thread, check if package manager is busy (utility function available) and if so, sleep for some time (say 1hour) and increment try count.
- If try count is more than a limit (say 10), exit the thread. Optionally, send notification to user using the notification framework (which is yet to be implemented) that some Plinth modules could not be upgraded.
- If the package manager is not busy, look at all the modules one by one following dependency order (see module initialization code for dependency order) and see if any of them need upgrading. If so, upgrade the module.
- If a module fails to upgrade, send notification to user using the notification framework.
- When there are no more modules to be upgraded, exit thread.
If the proposal looks okay, let us mark this issue as ready-for-implementation.