From d8d86a6af1ac65147a301348b9adbc2467a54d49 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Tue, 5 Dec 2023 15:38:44 +0100 Subject: [PATCH] offline: Don't require docker restart if just app update The recent patch to the docker engine makes the docker engine restart redundant since app images are correctly registered just at the end of the image loading process. Signed-off-by: Mike Sul --- apps/aklite-offline/cmds.cpp | 11 +++++------ src/offline/client.cc | 11 +++++++---- src/offline/client.h | 3 ++- tests/aklite_offline_test.cc | 6 ++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/aklite-offline/cmds.cpp b/apps/aklite-offline/cmds.cpp index 25e52c43..2eaa2fec 100644 --- a/apps/aklite-offline/cmds.cpp +++ b/apps/aklite-offline/cmds.cpp @@ -37,6 +37,11 @@ int InstallCmd::installUpdate(const Config& cfg_in, const boost::filesystem::pat cfg_in, {src_dir / "tuf", src_dir / "ostree_repo", src_dir / "apps"}, nullptr, force_downgrade); switch (install_res) { + case offline::PostInstallAction::Ok: { + std::cout << "Please run `aklite-offline run` command to start the updated Apps\n"; + ret_code = 10; + break; + } case offline::PostInstallAction::NeedRebootForBootFw: { ret_code = 90; std::cout @@ -54,12 +59,6 @@ int InstallCmd::installUpdate(const Config& cfg_in, const boost::filesystem::pat "to apply installation and start the updated Apps (unless no Apps to update or dockerless system)\n"; break; } - case offline::PostInstallAction::NeedDockerRestart: { - std::cout << "Please restart `docker` service `systemctl restart docker` and execute `aklite-offline run` " - "command to start the updated Apps\n"; - ret_code = 101; - break; - } case offline::PostInstallAction::AlreadyInstalled: { std::cout << "The given Target has been already installed\n"; ret_code = EXIT_SUCCESS; diff --git a/src/offline/client.cc b/src/offline/client.cc index 22dbfabb..da037e9e 100644 --- a/src/offline/client.cc +++ b/src/offline/client.cc @@ -320,7 +320,11 @@ static void registerApps(const Uptane::Target& target, const boost::filesystem:: const Docker::HashedDigest config_digest(image_manifest["config"]["digest"].asString()); const auto image_repo{image_uri.registryHostname + "/" + image_uri.repo}; - LOG_INFO << "Registering image: " << image_uri_str << " -> " << config_digest(); + // The image "registration" is not needed since LmP v91 because of the docker patch that + // register image just afet it is been laoded to the docker store. + // However, we want to keep image registration anyway since a user may do downgrade, + // so the `run` command can be execute in the LmP < v91 which does not include the docker patch. + LOG_DEBUG << "Registering image: " << image_uri_str << " -> " << config_digest(); repositories["Repositories"][image_repo][image_uri_str] = config_digest(); } } @@ -421,10 +425,9 @@ PostInstallAction install(const Config& cfg_in, const UpdateSrc& src, } else if (client->config.pacman.type != ComposeAppManager::Name || client->appsInSync(target)) { post_install_action = PostInstallAction::AlreadyInstalled; } else { - // don't `install` since it will create/run containers and we don't want to do it - // before we register images and restart dockerd + // just download apps in the case of "app only" update client->storage->savePrimaryInstalledVersion(target, InstalledVersionUpdateMode::kPending); - post_install_action = PostInstallAction::NeedDockerRestart; + post_install_action = PostInstallAction::Ok; } if (client->config.pacman.type == ComposeAppManager::Name && diff --git a/src/offline/client.h b/src/offline/client.h index 60bb0a9f..1e555689 100644 --- a/src/offline/client.h +++ b/src/offline/client.h @@ -22,9 +22,10 @@ struct UpdateSrc { enum class PostInstallAction { Undefined = -1, + Ok, NeedReboot, NeedRebootForBootFw, - NeedDockerRestart, + // NeedDockerRestart, AlreadyInstalled, DowngradeAttempt }; diff --git a/tests/aklite_offline_test.cc b/tests/aklite_offline_test.cc index a190922d..a9828981 100644 --- a/tests/aklite_offline_test.cc +++ b/tests/aklite_offline_test.cc @@ -202,8 +202,7 @@ class AkliteOffline : public ::testing::Test { for (const auto& app : apps_not_to_preload) { boost::filesystem::remove_all(app_store_.appsDir() / app); } - ASSERT_EQ(install(), offline::PostInstallAction::NeedDockerRestart); - reloadDockerEngine(); + ASSERT_EQ(install(), offline::PostInstallAction::Ok); ASSERT_EQ(run(), offline::PostRunAction::Ok); if (add_installed_versions) { @@ -360,8 +359,7 @@ TEST_F(AkliteOffline, OfflineClientAppsOnly) { const auto target{addTarget({createApp("app-01")}, true)}; ASSERT_EQ(1, check().size()); ASSERT_TRUE(target.MatchTarget(check().front())); - ASSERT_EQ(install(), offline::PostInstallAction::NeedDockerRestart); - reloadDockerEngine(); + ASSERT_EQ(install(), offline::PostInstallAction::Ok); ASSERT_EQ(run(), offline::PostRunAction::Ok); ASSERT_TRUE(target.MatchTarget(getCurrent())); }