mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Change default EngineState to online (#7417)
Resolves https://github.com/sigp/lighthouse/issues/7414 The health endpoint returns a 503 if the engine state is offline. The default state for the engine is `Offline`. So until the first request to the EL is made and the state is updated, the health endpoint will keep returning 503s. This PR changes the default state to Online to avoid that. I don't think this causes any issues because in case the EL is actually offline, the first fcu will set the state to offline. Pending testing on kurtosis.
This commit is contained in:
@@ -26,8 +26,8 @@ const CACHED_RESPONSE_AGE_LIMIT: Duration = Duration::from_secs(900); // 15 minu
|
||||
/// Stores the remembered state of a engine.
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Eq, Default)]
|
||||
enum EngineStateInternal {
|
||||
Synced,
|
||||
#[default]
|
||||
Synced,
|
||||
Offline,
|
||||
Syncing,
|
||||
AuthFailed,
|
||||
@@ -403,12 +403,17 @@ mod tests {
|
||||
async fn test_state_notifier() {
|
||||
let mut state = State::default();
|
||||
let initial_state: EngineState = state.state.into();
|
||||
assert_eq!(initial_state, EngineState::Offline);
|
||||
state.update(EngineStateInternal::Synced);
|
||||
// default state is online
|
||||
assert_eq!(initial_state, EngineState::Online);
|
||||
|
||||
// a watcher that arrives after the first update.
|
||||
let mut watcher = state.watch();
|
||||
let new_state = watcher.next().await.expect("Last state is always present");
|
||||
assert_eq!(new_state, EngineState::Online);
|
||||
|
||||
// update to offline
|
||||
state.update(EngineStateInternal::Offline);
|
||||
let new_state = watcher.next().await.expect("Last state is always present");
|
||||
assert_eq!(new_state, EngineState::Offline);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2475,7 +2475,7 @@ impl ApiTester {
|
||||
is_syncing: false,
|
||||
is_optimistic: false,
|
||||
// these tests run without the Bellatrix fork enabled
|
||||
el_offline: true,
|
||||
el_offline: false,
|
||||
head_slot,
|
||||
sync_distance,
|
||||
};
|
||||
@@ -2539,11 +2539,11 @@ impl ApiTester {
|
||||
pub async fn test_get_node_health(self) -> Self {
|
||||
let status = self.client.get_node_health().await;
|
||||
match status {
|
||||
Ok(_) => {
|
||||
panic!("should return 503 error status code");
|
||||
Ok(status) => {
|
||||
assert_eq!(status, 200);
|
||||
}
|
||||
Err(e) => {
|
||||
assert_eq!(e.status().unwrap(), 503);
|
||||
Err(_) => {
|
||||
panic!("should return valid status");
|
||||
}
|
||||
}
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user