Skip to content

Commit

Permalink
[daemon] Remove absent instances in daemon c'tor
Browse files Browse the repository at this point in the history
Log and remove, from the db, instances whose images are missing when the
daemon comes back up. This covers cases where the user deletes instances
directly from the backend, or otherwise removes them from disk.
  • Loading branch information
ricab committed May 11, 2021
1 parent 45cf2c4 commit 8647f62
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,14 @@ mp::Daemon::Daemon(std::unique_ptr<const DaemonConfig> the_config)
}

auto vm_image = fetch_image_for(name, config->factory->fetch_type(), *config->vault);
if (!QFile::exists(vm_image.image_path))
{
mpl::log(mpl::Level::warning, category,
fmt::format("Could not find image for '{}'. Expected location: {}", name, vm_image.image_path));
invalid_specs.push_back(name);
continue;
}

const auto instance_dir = mp::utils::base_dir(vm_image.image_path);
const auto cloud_init_iso = instance_dir.filePath("cloud-init-config.iso");
mp::VirtualMachineDescription vm_desc{spec.num_cores,
Expand Down

0 comments on commit 8647f62

Please sign in to comment.