From a9d70905a0e08cc2d591225b2e6ecaf078bbd34d Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Fri, 1 Nov 2024 16:23:21 -0400 Subject: [PATCH] Don't do no-op transitions --- upstairs/src/client.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/upstairs/src/client.rs b/upstairs/src/client.rs index 062718fd5..01312f505 100644 --- a/upstairs/src/client.rs +++ b/upstairs/src/client.rs @@ -571,29 +571,35 @@ impl DownstairsClient { let current = &self.state; let new_state = match current { - DsState::Active | DsState::Offline => DsState::Offline, - - DsState::Faulted - | DsState::LiveRepair - | DsState::LiveRepairReady => DsState::Faulted, + DsState::Active => Some(DsState::Offline), + DsState::LiveRepair | DsState::LiveRepairReady => { + Some(DsState::Faulted) + } - DsState::New - | DsState::Deactivated + DsState::Deactivated | DsState::Reconcile | DsState::Disconnected | DsState::WaitQuorum | DsState::WaitActive - | DsState::Disabled => DsState::New, + | DsState::Disabled => Some(DsState::New), // If we have replaced a downstairs, don't forget that. - DsState::Replacing | DsState::Replaced => DsState::Replaced, + DsState::Replacing => Some(DsState::Replaced), + + // We stay in these states through the task restart + DsState::Offline + | DsState::Faulted + | DsState::New + | DsState::Replaced => None, DsState::Migrating => panic!(), }; // Jobs are skipped and replayed in `Downstairs::reinitialize`, which is // (probably) the caller of this function. - self.checked_state_transition(up_state, new_state); + if let Some(new_state) = new_state { + self.checked_state_transition(up_state, new_state); + } self.connection_id.update();