Skip to content

Commit

Permalink
composeappmanager: Stop apps only if rootfs update is expected
Browse files Browse the repository at this point in the history
Stop apps being updated only if ostree update and reboot is expected.
Stopping apps in the case of an "app-only" update is not optimal, as
it stops all app services/containers. In contrast, `docker compose up`
can handle this more efficiently by restarting only those service
containers whose images have been updated.

Signed-off-by: Mike Sul <[email protected]>
  • Loading branch information
mike-sul committed Nov 15, 2024
1 parent c27acbe commit b9f64c0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/composeappmanager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,19 @@ data::InstallationResult ComposeAppManager::install(const Uptane::Target& target
// the subsequent "sync target" process will restart the apps (excluding those removed from the configuration).
stopDisabledComposeApps(target);

// Stopping the Apps that is about to be updated so they are not started automatically by dockerd just after reboot.
// If ostree is not updated then the updated Apps will be started in this context.
// If ostree is updated and a device is suddenly rebooted before Apps installation, then
// it ensures that the previous version Apps are not automatically started on boot.
// If an installation failure happens, then the following "sync target" process will re-start
// the stopped Apps (app only rollback).
for (const auto& pair : cur_apps_to_fetch_and_update_) {
LOG_INFO << "Stopping App before updating it; " << pair.first << " -> " << pair.second;
auto& non_const_app_engine = (const_cast<ComposeAppManager*>(this))->app_engine_;
non_const_app_engine->stop({pair.first, pair.second});
if (getCurrent().sha256Hash() != target.sha256Hash()) {
// If this ostree + apps update, then stop the Apps that is about to be updated
// so they are not started automatically by dockerd just after reboot.
// If ostree is not updated then the updated Apps will be started in this context.
// If ostree is updated and a device is suddenly rebooted before Apps installation, then
// it ensures that the previous version Apps are not automatically started on boot.
// If an installation failure happens, then the following "sync target" process will re-start
// the stopped Apps (app only rollback).
for (const auto& pair : cur_apps_to_fetch_and_update_) {
LOG_INFO << "Stopping App before updating it; " << pair.first << " -> " << pair.second;
auto& non_const_app_engine = (const_cast<ComposeAppManager*>(this))->app_engine_;
non_const_app_engine->stop({pair.first, pair.second});
}
}

data::InstallationResult res{RootfsTreeManager::install(target)};
Expand Down

0 comments on commit b9f64c0

Please sign in to comment.