Skip to content

Commit

Permalink
bug: Add errors for health check reporting (#610)
Browse files Browse the repository at this point in the history
(NOTE: This uses the `error!()` macro.)
  • Loading branch information
jrconlin authored Feb 8, 2024
1 parent 9bb964c commit 37a0724
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 12 additions & 1 deletion autoconnect/autoconnect-web/src/dockerflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@ pub fn config(config: &mut web::ServiceConfig) {
}

/// Handle the `/health` and `/__heartbeat__` routes
// note, this changes to `blocks_in_conditions` for 1.76+
#[allow(clippy::blocks_in_if_conditions)]
pub async fn health_route(state: Data<AppState>) -> Json<serde_json::Value> {
let status = if state.db.health_check().await.is_ok() {
let status = if state
.db
.health_check()
.await
.map_err(|e| {
error!("Autoconnect Health Error: {:?}", e);
e
})
.is_ok()
{
"OK"
} else {
"ERROR"
Expand Down
11 changes: 7 additions & 4 deletions autoendpoint/src/routes/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ fn interpret_table_health(health: DbResult<bool>) -> serde_json::Value {
"status": "NOT OK",
"cause": "Nonexistent table"
}),
Err(e) => json!({
"status": "NOT OK",
"cause": e.to_string()
}),
Err(e) => {
error!("Autoendpoint health error: {:?}", e);
json!({
"status": "NOT OK",
"cause": e.to_string()
})
}
}
}

Expand Down
1 change: 1 addition & 0 deletions autopush-common/src/db/bigtable/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl Manager for BigtableClientManager {
}

// Clippy 0.1.73 complains about the `.map_err` being hard to read.
// note, this changes to `blocks_in_conditions` for 1.76+
#[allow(clippy::blocks_in_if_conditions)]
if !client
.health_check(&self.settings.table_name)
Expand Down

0 comments on commit 37a0724

Please sign in to comment.