Skip to content

Commit

Permalink
Merge branch 'main' into paul/dis-2207-plane-connecting-to-a-session-…
Browse files Browse the repository at this point in the history
…backend-before-it-is-ready
  • Loading branch information
paulgb authored Jul 9, 2024
2 parents 185cb45 + f10c629 commit 9326f4d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
13 changes: 7 additions & 6 deletions plane/src/drone/backend_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<R: Runtime> BackendManager<R> {
TerminationReason::StartupTimeout,
)
} else {
state.to_ready()
state.to_ready(address)
}
})
}
Expand All @@ -195,17 +195,18 @@ impl<R: Runtime> BackendManager<R> {
.terminate(&backend_id, termination == TerminationKind::Hard)
.await
{
Ok(_) => break,
Ok(false) => return state.to_terminated(None),
Ok(true) => {
// Return a future that never resolves, so that only the container
// terminating bumps us into the next state.
return pending().await;
}
Err(err) => {
tracing::error!(?err, "failed to terminate backend");
backoff.wait().await;
}
}
}

// Return a future that never resolves, so that only the container
// terminating bumps us into the next state.
pending().await
})
}
BackendState::Terminated { .. } => StepStatusResult::DoNothing,
Expand Down
18 changes: 9 additions & 9 deletions plane/src/drone/state_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ mod test {
.register_event(
&backend_id,
&BackendState::Ready {
address: Some(dummy_addr()),
address: dummy_addr(),
},
Utc::now(),
)
Expand All @@ -268,7 +268,7 @@ mod test {
assert_eq!(
result,
BackendState::Ready {
address: Some(dummy_addr())
address: dummy_addr()
}
);
}
Expand All @@ -280,7 +280,7 @@ mod test {
let backend_id = BackendName::new_random();

let ready_state = BackendState::Ready {
address: Some(dummy_addr()),
address: dummy_addr(),
};
{
state_store
Expand All @@ -291,7 +291,7 @@ mod test {
assert_eq!(
result,
BackendState::Ready {
address: Some(dummy_addr())
address: dummy_addr()
}
);
}
Expand Down Expand Up @@ -333,7 +333,7 @@ mod test {
let backend_id = BackendName::new_random();

let ready_state = BackendState::Ready {
address: Some(dummy_addr()),
address: dummy_addr(),
};
state_store
.register_event(&backend_id, &ready_state, Utc::now())
Expand All @@ -348,7 +348,7 @@ mod test {
assert_eq!(
event.state,
BackendState::Ready {
address: Some(dummy_addr())
address: dummy_addr()
}
);
}
Expand Down Expand Up @@ -391,7 +391,7 @@ mod test {
let backend_id = BackendName::new_random();

let ready_state = BackendState::Ready {
address: Some(dummy_addr()),
address: dummy_addr(),
};
state_store
.register_event(&backend_id, &ready_state, Utc::now())
Expand All @@ -418,7 +418,7 @@ mod test {
assert_eq!(
event.state,
BackendState::Ready {
address: Some(dummy_addr())
address: dummy_addr()
}
);
}
Expand Down Expand Up @@ -453,7 +453,7 @@ mod test {
assert_eq!(
event.state,
BackendState::Ready {
address: Some(dummy_addr())
address: dummy_addr()
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion plane/src/typed_unix_socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct WrappedMessage<T> {
/// Optional ID for this message. If it is provided, this message belongs to a request/response pair
/// (either as the request or the response). If it is not provided, this message is an event.
id: Option<String>,
message: T,
pub message: T,
}

fn get_quick_backoff() -> ExponentialBackoff {
Expand Down
16 changes: 4 additions & 12 deletions plane/src/types/backend_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub enum BackendState {
address: BackendAddr,
},
Ready {
address: Option<BackendAddr>,
address: BackendAddr,
},
Terminating {
last_status: BackendStatus,
Expand Down Expand Up @@ -234,7 +234,7 @@ impl BackendState {
pub fn address(&self) -> Option<BackendAddr> {
match self {
BackendState::Waiting { address } => Some(*address),
BackendState::Ready { address } => *address,
BackendState::Ready { address } => Some(*address),
_ => None,
}
}
Expand Down Expand Up @@ -269,16 +269,8 @@ impl BackendState {
}
}

pub fn to_ready(&self) -> BackendState {
match self {
BackendState::Waiting { address } => BackendState::Ready {
address: Some(*address),
},
_ => {
tracing::warn!("to_ready called on non-waiting backend");
BackendState::Ready { address: None }
}
}
pub fn to_ready(&self, address: BackendAddr) -> BackendState {
BackendState::Ready { address }
}

pub fn to_terminating(
Expand Down

0 comments on commit 9326f4d

Please sign in to comment.