Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more unnecessary DsState variants #1550

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cmon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,11 @@ fn short_state(dss: DsState) -> String {
DsState::New => "NEW".to_string(),
DsState::WaitActive => "WAC".to_string(),
DsState::WaitQuorum => "WAQ".to_string(),
DsState::Disconnected => "DIS".to_string(),
DsState::Reconcile => "REC".to_string(),
DsState::Active => "ACT".to_string(),
DsState::Faulted => "FLT".to_string(),
DsState::LiveRepairReady => "LRR".to_string(),
DsState::LiveRepair => "LR".to_string(),
DsState::Migrating => "MIG".to_string(),
DsState::Offline => "OFF".to_string(),
DsState::Deactivated => "DAV".to_string(),
DsState::Disabled => "DIS".to_string(),
Expand Down
2 changes: 0 additions & 2 deletions openapi/crucible-control.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@
"new",
"wait_active",
"wait_quorum",
"disconnected",
"reconcile",
"active",
"faulted",
"live_repair_ready",
"live_repair",
"migrating",
"offline",
"deactivated",
"disabled",
Expand Down
17 changes: 2 additions & 15 deletions upstairs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ impl DownstairsClient {

DsState::Deactivated
| DsState::Reconcile
| DsState::Disconnected
| DsState::WaitQuorum
| DsState::WaitActive
| DsState::Disabled => Some(DsState::New),
Expand All @@ -591,8 +590,6 @@ impl DownstairsClient {
| DsState::Faulted
| DsState::New
| DsState::Replaced => None,

DsState::Migrating => panic!(),
};

// Jobs are skipped and replayed in `Downstairs::reinitialize`, which is
Expand Down Expand Up @@ -846,7 +843,6 @@ impl DownstairsClient {
let new_state = match self.state {
DsState::Active => DsState::Offline,
DsState::Offline => DsState::Offline,
DsState::Migrating => DsState::Faulted,
DsState::Faulted => DsState::Faulted,
DsState::Deactivated => DsState::New,
DsState::Reconcile => DsState::New,
Expand All @@ -859,7 +855,7 @@ impl DownstairsClient {
* downstairs to receive IO, so we go to the back of the
* line and have to re-verify it again.
*/
DsState::Disconnected
DsState::New
}
};

Expand Down Expand Up @@ -960,11 +956,9 @@ impl DownstairsClient {
DsState::New
| DsState::WaitActive
| DsState::WaitQuorum
| DsState::Disconnected
| DsState::Reconcile
| DsState::Deactivated
| DsState::Disabled
| DsState::Migrating => panic!(
| DsState::Disabled => panic!(
"enqueue should not be called from state {:?}",
self.state
),
Expand Down Expand Up @@ -1045,7 +1039,6 @@ impl DownstairsClient {
}
} else if old_state != DsState::New
&& old_state != DsState::Faulted
&& old_state != DsState::Disconnected
&& old_state != DsState::Replaced
{
panic!(
Expand Down Expand Up @@ -1157,12 +1150,6 @@ impl DownstairsClient {
// A move to Disabled can happen at any time we are talking
// to a downstairs.
}
_ => {
panic!(
"[{}] Missing check for transition {} to {}",
self.client_id, old_state, new_state
);
}
}

if old_state != new_state {
Expand Down
34 changes: 9 additions & 25 deletions upstairs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,17 +715,17 @@ pub(crate) struct RawReadResponse {
* ┌─────────────► New ╞═════◄════════════════╗ ║
* │ ┌─────► ├─────◄──────┐ ║ ║
* │ │ └────┬───┬──┘ │ ║ ║
* │ │ ▼ └───►───┐ │ ║ ║
* │ bad│ ┌────┴──────┐ │ ║ ║
* │ region│ │ Wait │ │ ║ ║
* │ │ ▼ └───►───┐ other │ ║ ║
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, we probably don't need the arrow going form new -> new.

* │ bad│ ┌────┴──────┐ │ failures ║ ║
Comment on lines +718 to +719
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other failures, other than the connection going away?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, going back to New is the universal behavior for any failures before going active.

* │ region│ │ Wait │ │ ║ ║
* │ │ │ Active ├─►┐ │ │ ║ ║
* │ │ └────┬──────┘ │ │ ┌────┴───────┐ ║ ║
* │ │ ┌────┴──────┐ │ └──┤ ║ ║
* │ │ │ Wait │ └────┤Disconnected│ ║ ║
* │ └─────┤ Quorum ├──►────┤ ║ ║
* │ └────┬──────┘ └────┬───────┘ ║ ║
* │ │ └────┬──────┘ │ │ ║ ║
* │ │ ┌────┴──────┐ │ └───────┤ ║ ║
* │ │ │ Wait │ └─────────┤ ║ ║
* │ └─────┤ Quorum ├──►─────────┤ ║ ║
* │ └────┬──────┘ ║ ║
* │ ........▼.......... │ ║ ║
* │failed : ┌────┴──────┐ : ║ ║
* │failed : ┌────┴──────┐ : ║ ║
* │reconcile : │ Reconcile │ : │ ╔═╝ ║
* └─────────────┤ ├──►─────────┘ ║ ║
* : └────┬──────┘ : ║ ║
Expand Down Expand Up @@ -786,12 +786,6 @@ pub enum DsState {
* Waiting for the minimum number of downstairs to be present.
*/
WaitQuorum,
/*
* We were connected, but did not transition all the way to
* active before the connection went away. Arriving here means the
* downstairs has to go back through the whole negotiation process.
*/
Disconnected,
/*
* Initial startup, downstairs are repairing from each other.
*/
Expand All @@ -815,10 +809,6 @@ pub enum DsState {
* This downstairs is undergoing LiveRepair
*/
LiveRepair,
/*
* This downstairs is being migrated to a new location
*/
Migrating,
/*
* This downstairs was active, but is now no longer connected.
* We may have work for it in memory, so a replay is possible
Expand Down Expand Up @@ -858,9 +848,6 @@ impl std::fmt::Display for DsState {
DsState::WaitQuorum => {
write!(f, "WaitQuorum")
}
DsState::Disconnected => {
write!(f, "Disconnected")
}
DsState::Reconcile => {
write!(f, "Reconcile")
}
Expand All @@ -876,9 +863,6 @@ impl std::fmt::Display for DsState {
DsState::LiveRepair => {
write!(f, "LiveRepair")
}
DsState::Migrating => {
write!(f, "Migrating")
}
DsState::Offline => {
write!(f, "Offline")
}
Expand Down