Skip to content

Commit 0000453

Browse files
committed
[review] Address review feedback
- Restore missing 'starting' state check in VirtualBox current_state - Fix VirtualBox current_state to detect stopped state immediately - Remove duplicate TODO comment in wait_for_cloud_init - Remove extra newline in wait_for_cloud_init - Add if constexpr check to only treat IntentionalShutdownException as success for LaunchRequest, not StartRequest
1 parent 637c79c commit 0000453

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/daemon/daemon.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,12 +3567,18 @@ error_string mp::Daemon::async_wait_for_ssh_and_start_mounts_for(
35673567
vm->wait_for_cloud_init(timeout);
35683568
}
35693569
}
3570-
catch (const mp::IntentionalShutdownException&)
3570+
catch (const mp::IntentionalShutdownException& e)
35713571
{
3572-
mpl::log(mpl::Level::info,
3573-
name,
3574-
"Instance powered off intentionally during initialization");
3575-
return {}; // Success - intentional shutdown
3572+
if constexpr (std::is_same_v<Request, LaunchRequest>)
3573+
{
3574+
mpl::log(mpl::Level::info, name,
3575+
"Instance powered off intentionally during initialization");
3576+
return {}; // Success - intentional shutdown
3577+
}
3578+
else
3579+
{
3580+
throw StartException(name, "Unexpected shutdown during start");
3581+
}
35763582
}
35773583

35783584
if (MP_SETTINGS.get_as<bool>(mp::mounts_key))

src/platform/backends/shared/base_virtual_machine.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,12 @@ void mp::BaseVirtualMachine::wait_for_cloud_init(std::chrono::milliseconds timeo
316316
try_to_ssh();
317317
return mpu::TimeoutAction::retry;
318318
}
319-
catch (const SSHExecFailure& e) // transitioning away from catching generic runtime errors
320-
{ // TODO remove once we're confident this is an anomaly
319+
catch (const SSHExecFailure& e)
320+
{
321321
return mpu::TimeoutAction::retry;
322322
}
323-
catch (const std::exception& e)
324-
{
323+
catch (const std::exception& e) // transitioning away from catching generic runtime errors
324+
{ // TODO remove once we're confident this is an anomaly
325325
mpl::log_message(mpl::Level::warning, vm_name, e.what());
326326
return mpu::TimeoutAction::retry;
327327
}
@@ -330,7 +330,6 @@ void mp::BaseVirtualMachine::wait_for_cloud_init(std::chrono::milliseconds timeo
330330
auto on_timeout = [] {
331331
throw std::runtime_error("timed out waiting for initialization to complete");
332332
};
333-
334333
mpu::try_action_for(on_timeout, timeout, action);
335334
}
336335

src/platform/backends/virtualbox/virtualbox_virtual_machine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ void mp::VirtualBoxVirtualMachine::suspend()
448448
mp::VirtualMachine::State mp::VirtualBoxVirtualMachine::current_state()
449449
{
450450
auto present_state = instance_state_for(name);
451-
if (state == State::delayed_shutdown && present_state == State::running)
451+
if ((state == State::delayed_shutdown && present_state == State::running) || state == State::starting)
452452
return state;
453-
453+
454454
state = present_state;
455455
if (state == State::suspended || state == State::suspending)
456456
drop_ssh_session();

0 commit comments

Comments
 (0)