Skip to content

Commit

Permalink
[daemon] Avoid fixing state from off to stopped
Browse files Browse the repository at this point in the history
Avoid fixing the state of deleted instances from off to stopped, along
with incoherent log "<instance> is deleted but has incompatible state 0,
resetting state to 0 (stopped)".
  • Loading branch information
ricab committed Jan 12, 2024
1 parent d84f8f7 commit 09fe713
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 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)
{
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)));
if (spec.deleted && spec.state != VirtualMachine::State::stopped && spec.state != VirtualMachine::State::off)
{
mpl::log(mpl::Level::warning,

Check warning on line 1485 in src/daemon/daemon.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/daemon.cpp#L1485

Added line #L1485 was not covered by tests
category,
fmt::format("{} is deleted but has incompatible state {}, resetting state to {} (stopped)",

Check warning on line 1487 in src/daemon/daemon.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/daemon.cpp#L1487

Added line #L1487 was not covered by tests
name,
static_cast<int>(spec.state),
static_cast<int>(VirtualMachine::State::stopped)));

Check warning on line 1490 in src/daemon/daemon.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/daemon.cpp#L1489-L1490

Added lines #L1489 - L1490 were not covered by tests
spec.state = VirtualMachine::State::stopped;
}

Expand Down

0 comments on commit 09fe713

Please sign in to comment.