mock: attempt realistic state transitions #860
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Presently, when the mock
propolis-server
receives a put-state requestfor
Stopped
, it setsself.state
toStopped
and shuts down the mockserial console, here:
propolis/bin/mock-server/src/lib/lib.rs
Lines 107 to 111 in c849bab
However, it never actually sets the
state_watcher
state, which iswhat's used by the
instance_state_monitor
endpoint, toStopping
,the way we do for other state transitions:
propolis/bin/mock-server/src/lib/lib.rs
Lines 92 to 106 in c849bab
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.
In real life, stopping an instance will cause it to go through multiple
state transitions: first to
Stopping
and then toStopped
. This alsoCurrently, the mock doesn't have a way to cause multiple state transitions
to be observed by the
instance_state_monitor
client. Therefore, I'vechanged the implementation to support this, using a map of states by
generation number. Now, when the state monitor requests the next state
transition from a given generation, we will return the state at
gen + 1
in that map if one exists, or wait until more states areadded to the map. Transitions that cause the instance to go through
multiple states will now add all of those states to the queue of states
to simulate.
The state used by
instance_get
and for determining what statetransitions are updated is now represented by a variable tracking the
current state generation. This is updated only once we expose a new
state to the
instance_state_monitor
client, so the understanding ofthe instance's state used to determine what requested transitions
are valid is kept in sync with what we've claimed to be from the state
monitor's perspective.
Testing: I've pointed the
omicron
repo'spropolis-mock-server
depat commit 28d81cb and run
cargo nextest run -p omicron-sled-agent
.1 All the tests still pass.Fixes #857
Footnotes
I believe only the sled-agent test suite uses
propolis-mock-server
? ↩