Skip to content

Commit

Permalink
offline: Don't require docker restart if just app update
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mike-sul committed Dec 5, 2023
1 parent 24fb3c4 commit d8d86a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
11 changes: 5 additions & 6 deletions apps/aklite-offline/cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions src/offline/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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 &&
Expand Down
3 changes: 2 additions & 1 deletion src/offline/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ struct UpdateSrc {

enum class PostInstallAction {
Undefined = -1,
Ok,
NeedReboot,
NeedRebootForBootFw,
NeedDockerRestart,
// NeedDockerRestart,
AlreadyInstalled,
DowngradeAttempt
};
Expand Down
6 changes: 2 additions & 4 deletions tests/aklite_offline_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()));
}
Expand Down

0 comments on commit d8d86a6

Please sign in to comment.