Skip to content

mock-server doesn't simulate instance stop #857

@hawkw

Description

@hawkw

Presently, when the mock propolis-server receives a put-state request for Stopped, it sets self.state to Stopped and shuts down the mock serial console, here:

api::InstanceStateRequested::Stop => {
self.state = api::InstanceState::Stopped;
self.serial_task.shutdown().await;
Ok(())
}

However, it never actually sets the state_watcher state, which is what's used by the instance_state_monitor endpoint, to Stopping`, the way we do for other state transitions:

api::InstanceStateRequested::Run
| api::InstanceStateRequested::Reboot => {
self.generation += 1;
self.state = api::InstanceState::Running;
self.state_watcher_tx
.send(api::InstanceStateMonitorResponse {
gen: self.generation,
state: self.state,
migration: api::InstanceMigrateStatusResponse {
migration_in: None,
migration_out: None,
},
})
.map_err(|_| Error::TransitionSendFail)
}

self.state isn't used for simulating the state-monitor endpoint, it's just used for validating state transitions. This means that the mock server will never actually appear to transition to Stopping and then to Stopped from the perspective of a sled-agent that's long-polling the instance_state_monitor endpoint.

If we want to actually use the mock server to test sled-agent behavior around instance stop, we need to make it behave realistically here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions