mock: attempt realistic state transitions#860
Merged
Conversation
gjcolombo
approved these changes
Feb 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-serverreceives a put-state requestfor
Stopped, it setsself.statetoStoppedand 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_watcherstate, which iswhat's used by the
instance_state_monitorendpoint, 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
Stoppingand then toStopped. This alsoCurrently, the mock doesn't have a way to cause multiple state transitions
to be observed by the
instance_state_monitorclient. 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 + 1in 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_getand 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_monitorclient, 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
omicronrepo'spropolis-mock-serverdepat 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? ↩