-
Notifications
You must be signed in to change notification settings - Fork 31
Description
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:
propolis/bin/mock-server/src/lib/lib.rs
Lines 107 to 111 in c849bab
| 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:
propolis/bin/mock-server/src/lib/lib.rs
Lines 92 to 106 in c849bab
| 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.