Skip to content

Commit

Permalink
All tests passing!
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Nov 25, 2024
1 parent 3818b40 commit 79652b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion openapi/crucible-control.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
"description": "Tracks client negotiation progress",
"oneOf": [
{
"description": "Initial state",
"description": "Initial state, waiting to hear `YesItsMe` from the client\n\nOnce this message is heard, transitions to either `WaitActive` (if `auto_promote` is `false`) or `WaitQuorum` (if `auto_promote` is `true`)",
"type": "object",
"properties": {
"type": {
Expand Down
20 changes: 18 additions & 2 deletions upstairs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,6 @@ impl DownstairsClient {
/// error is at or after `Message::YouAreNowActive`.
///
/// Returns a flag indicating how to proceed
#[must_use]
pub(crate) fn continue_negotiation(
&mut self,
m: Message,
Expand Down Expand Up @@ -1626,6 +1625,20 @@ impl DownstairsClient {
*state = NegotiationState::WaitQuorum;
out = NegotiationResult::WaitQuorum;
}
// Special case: if a downstairs is replaced while we're
// still trying to go active, then we use the WaitQuorum
// path instead of LiveRepair.
ConnectionMode::Replaced
if matches!(
up_state,
UpstairsState::Initializing
| UpstairsState::GoActive(..)
) =>
{
*state = NegotiationState::WaitQuorum;
out = NegotiationResult::WaitQuorum;
}

ConnectionMode::Faulted | ConnectionMode::Replaced => {
*state = NegotiationState::LiveRepairReady;
out = NegotiationResult::LiveRepair;
Expand Down Expand Up @@ -1793,7 +1806,10 @@ impl DownstairsClient {
#[serde(rename_all = "snake_case")]
#[serde(tag = "type", content = "value")]
pub enum NegotiationState {
/// Initial state
/// Initial state, waiting to hear `YesItsMe` from the client
///
/// Once this message is heard, transitions to either `WaitActive` (if
/// `auto_promote` is `false`) or `WaitQuorum` (if `auto_promote` is `true`)
Start {
auto_promote: bool,
},
Expand Down
10 changes: 9 additions & 1 deletion upstairs/src/downstairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,14 @@ impl Downstairs {
continue;
}
match self.clients[client_id].state() {
// Replacement is allowed before starting, but not between
// activation and coming online
DsState::Connecting {
state:
NegotiationState::Start { .. }
| NegotiationState::WaitActive,
mode: ConnectionMode::New,
} => {}
DsState::Stopping(..)
| DsState::Connecting { .. }
| DsState::LiveRepair => {
Expand All @@ -2603,7 +2611,7 @@ impl Downstairs {
self.clients[client_id].state(),
)));
}
_ => {}
DsState::Active => {}
}
}

Expand Down

0 comments on commit 79652b6

Please sign in to comment.