-
Notifications
You must be signed in to change notification settings - Fork 19
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
Consolidate DownstairsClient::reinitialize
#1549
Conversation
@@ -523,27 +515,19 @@ impl Downstairs { | |||
// Specifically, we want to skip jobs if the only path back online for | |||
// that client goes through live-repair; if that client can come back | |||
// through replay, then the jobs must remain live. | |||
let new_state = self.clients[client_id].state(); | |||
if matches!(prev_state, DsState::LiveRepair | DsState::Active) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was impossible to go from Active
→ Faulted
; in the previous implementation of on_missing
, Active
always became Offline
. Therefore, this branch only fired if the incoming state is LiveRepair
.
57097ed
to
67a20d7
Compare
@@ -1858,7 +1849,6 @@ impl DownstairsClient { | |||
String::new() | |||
}, | |||
); | |||
self.checked_state_transition(up_state, DsState::New); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a drive-by change: the calls to restart_connection
below always update the state, so doing it here is superfluous.
// If the upstairs is already active (or trying to go active), then the | ||
// downstairs should automatically call PromoteToActive when it reaches | ||
// the relevant state. | ||
let auto_promote = match self.state { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto_promote
is a deterministic function of self.state
, so we don't need to compute it here (because we're passing &self.state
into the function below).
67a20d7
to
489e0d5
Compare
7c40c94
to
a9d7090
Compare
Previously,
Downstairs::reinitialize
would do the following:DownstairsClient::on_missing
, which updates the client stateDownstairsClient::reinitialize
, which also updates client stateThese used to be separate tasks, but they're now in the same place, so it's silly to have them both.
This PR consolidates all of the logic into
DownstairsClient::reinitialize
.