Skip to content

Commit

Permalink
Merge pull request #3367 from canonical/avoid-state-fix-from-off-to-s…
Browse files Browse the repository at this point in the history
…topped

[daemon] Avoid fixing state from off to stopped
  • Loading branch information
Chris Townsend authored Jan 13, 2024
2 parents eb769b9 + 09fe713 commit 0b7e88a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,11 +1480,14 @@ mp::Daemon::Daemon(std::unique_ptr<const DaemonConfig> the_config)
allocated_mac_addrs = std::move(new_macs); // Add the new macs to the daemon's list only if we got this far

// FIXME: somehow we're writing contradictory state to disk.
if (spec.deleted && spec.state != VirtualMachine::State::stopped)
if (spec.deleted && spec.state != VirtualMachine::State::stopped && spec.state != VirtualMachine::State::off)
{
mpl::log(mpl::Level::warning, category,
fmt::format("{} is deleted but has incompatible state {}, resetting state to 0 (stopped)", name,
static_cast<int>(spec.state)));
mpl::log(mpl::Level::warning,
category,
fmt::format("{} is deleted but has incompatible state {}, resetting state to {} (stopped)",
name,
static_cast<int>(spec.state),
static_cast<int>(VirtualMachine::State::stopped)));
spec.state = VirtualMachine::State::stopped;
}

Expand Down

0 comments on commit 0b7e88a

Please sign in to comment.