From 6b9898271921677d13d2a503666902433711e931 Mon Sep 17 00:00:00 2001 From: Stan Drozd Date: Tue, 28 Feb 2023 16:29:12 +0100 Subject: [PATCH] wormhole_attester client: Change "not enough data" HTTP code to 503 Previously, we used 307 Internal Redirect to tell k8s that we're still waiting for the healthcheck window to fill up. Unfortunately, k8s assumes 3XX as a success, which wrongly tells it that the service is ready. Changing to 503 causes the expected probe failure to appear when the healthcheck state is not yet determined. --- wormhole_attester/Cargo.lock | 2 +- wormhole_attester/client/Cargo.toml | 2 +- wormhole_attester/client/src/util.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wormhole_attester/Cargo.lock b/wormhole_attester/Cargo.lock index 7b9420b7b2..aac12e2314 100644 --- a/wormhole_attester/Cargo.lock +++ b/wormhole_attester/Cargo.lock @@ -2699,7 +2699,7 @@ dependencies = [ [[package]] name = "pyth-wormhole-attester-client" -version = "4.0.0" +version = "4.1.0" dependencies = [ "borsh", "clap 3.1.18", diff --git a/wormhole_attester/client/Cargo.toml b/wormhole_attester/client/Cargo.toml index a9912f8916..03f155448c 100644 --- a/wormhole_attester/client/Cargo.toml +++ b/wormhole_attester/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyth-wormhole-attester-client" -version = "4.0.0" +version = "4.1.0" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/wormhole_attester/client/src/util.rs b/wormhole_attester/client/src/util.rs index 4544d89a3c..2acdee0af2 100644 --- a/wormhole_attester/client/src/util.rs +++ b/wormhole_attester/client/src/util.rs @@ -142,15 +142,15 @@ async fn healthcheck_handler() -> Result { ); Ok(reply::with_status(msg, StatusCode::OK)) } - // Unhealthy - 503 Service Unavailable + // Unhealthy - 500 Internal Server Error Some(false) => { let msg = format!( "unhealthy, all of {} latest attestations returned error", hc_state.max_window_size ); - Ok(reply::with_status(msg, StatusCode::SERVICE_UNAVAILABLE)) + Ok(reply::with_status(msg, StatusCode::INTERNAL_SERVER_ERROR)) } - // No data - 307 Temporary Redirect + // No data - 503 Service Unavailable None => { let msg = if hc_state.enable { format!( @@ -161,7 +161,7 @@ async fn healthcheck_handler() -> Result { } else { "Healthcheck disabled (enable_healthcheck is false)".to_string() }; - Ok(reply::with_status(msg, StatusCode::TEMPORARY_REDIRECT)) + Ok(reply::with_status(msg, StatusCode::SERVICE_UNAVAILABLE)) } } }