-
Notifications
You must be signed in to change notification settings - Fork 1k
Audit of warn! and error! #5640
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,7 @@ impl Host { | |
| ) | ||
| .await | ||
| .map_err(|e| { | ||
| // TODO: Review log level after user SQL errors can be distinguished from internal database failures. | ||
| log::warn!("{e}"); | ||
| (StatusCode::BAD_REQUEST, e.to_string()) | ||
| })?; | ||
|
|
@@ -638,6 +639,7 @@ impl<T: Authorization> Authorization for Arc<T> { | |
| } | ||
| } | ||
|
|
||
| // TODO: Review each caller and split this helper by the appropriate log severity. | ||
| pub fn log_and_500(e: impl std::fmt::Display) -> ErrorResponse { | ||
| log::error!("internal error: {e:#}"); | ||
| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#}")).into() | ||
|
Comment on lines
+642
to
645
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be very broadly used which makes it hard to know if it should be reduced from |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,20 +119,32 @@ pub(crate) fn map_reducer_error(e: ReducerCallError, reducer: &str) -> (StatusCo | |
| } | ||
|
|
||
| fn map_procedure_error(e: ProcedureCallError, procedure: &str) -> (StatusCode, String) { | ||
| let status_code = match e { | ||
| let status_code = match &e { | ||
| ProcedureCallError::Args(_) => { | ||
| // TODO: Remove this host log once the error is logged to the guest log instead. | ||
| log::debug!("Attempt to call procedure {procedure} with invalid arguments"); | ||
| StatusCode::BAD_REQUEST | ||
| } | ||
| ProcedureCallError::NoSuchModule(_) => StatusCode::NOT_FOUND, | ||
| ProcedureCallError::NoSuchModule(_) => { | ||
| log::debug!("Attempt to call procedure {procedure} on a module that is not available"); | ||
| StatusCode::NOT_FOUND | ||
| } | ||
| ProcedureCallError::NoSuchProcedure => { | ||
| // TODO: Remove this host log once the error is logged to the guest log instead. | ||
| log::debug!("Attempt to call non-existent procedure OR reducer {procedure}"); | ||
| StatusCode::NOT_FOUND | ||
| } | ||
| ProcedureCallError::OutOfEnergy => StatusCode::PAYMENT_REQUIRED, | ||
| ProcedureCallError::InternalError(_) => StatusCode::INTERNAL_SERVER_ERROR, | ||
| ProcedureCallError::OutOfEnergy => { | ||
| // TODO: Remove this host log once the error is logged to the guest log instead. | ||
| log::info!("Procedure {procedure} could not run because the module is out of energy"); | ||
| StatusCode::PAYMENT_REQUIRED | ||
| } | ||
| ProcedureCallError::InternalError(_) => { | ||
| // TODO: May need to split this from module errors vs host errors | ||
| log::warn!("Internal error while invoking procedure {procedure}: {e:#}"); | ||
| StatusCode::INTERNAL_SERVER_ERROR | ||
|
Comment on lines
+143
to
+145
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we preserve whether this failure came from module code or the host? Module errors should remain low-level and eventually go to module logs, while internal host failures may need to stay at |
||
| } | ||
| }; | ||
| log::error!("Error while invoking procedure {e:#}"); | ||
| (status_code, format!("{:#}", anyhow::anyhow!(e))) | ||
| } | ||
|
|
||
|
|
@@ -422,7 +434,7 @@ fn reducer_outcome_response( | |
| (StatusCode::from_u16(530).unwrap(), *errmsg) | ||
| } | ||
| ReducerOutcome::BudgetExceeded => { | ||
| log::warn!("Node's energy budget exceeded for identity: {owner_identity} while executing {reducer}"); | ||
| log::info!("Node's energy budget exceeded for identity: {owner_identity} while executing {reducer}"); | ||
| (StatusCode::PAYMENT_REQUIRED, "Module energy budget exhausted.".into()) | ||
| } | ||
| } | ||
|
|
@@ -468,7 +480,7 @@ pub(crate) async fn find_leader_and_database<S: ControlStateDelegate + NodeDeleg | |
| let database = worker_ctx_find_database(worker_ctx, &db_identity) | ||
| .await? | ||
| .ok_or_else(|| { | ||
| log::error!("Could not find database: {}", db_identity.to_hex()); | ||
| log::debug!("Could not find database: {}", db_identity.to_hex()); | ||
| NO_SUCH_DATABASE | ||
| })?; | ||
|
|
||
|
|
@@ -1528,7 +1540,7 @@ async fn get_timestamp<S: ControlStateDelegate>( | |
| let _database = worker_ctx_find_database(&worker_ctx, &db_identity) | ||
| .await? | ||
| .ok_or_else(|| { | ||
| log::error!("Could not find database: {}", db_identity.to_hex()); | ||
| log::debug!("Could not find database: {}", db_identity.to_hex()); | ||
| NO_SUCH_DATABASE | ||
| })?; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,7 +240,7 @@ where | |
| Ok(ws) => ws, | ||
| Err(err) => { | ||
| record_client_rejection(db_identity, ClientRejectCause::WebsocketUpgradeError); | ||
| log::error!("websocket: WebSocket init error: {err}"); | ||
| log::warn!("websocket: WebSocket init error: {err}"); | ||
| return; | ||
| } | ||
| }; | ||
|
|
@@ -855,6 +855,7 @@ async fn ws_recv_task<MessageHandler>( | |
| if ws_version == WsVersion::V1 | ||
| && let MessageHandleError::Execution(err) = e | ||
| { | ||
| // TODO: Review log level after guest/client execution errors can be distinguished from internal failures. | ||
| log::error!("{err:#}"); | ||
| // If the send task has exited, also exit this recv task. | ||
| if unordered_tx.send(err.into()).is_err() { | ||
|
Comment on lines
855
to
861
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks to combine module errors with possible host errors, that leads me to lean |
||
|
|
@@ -1001,7 +1002,7 @@ fn ws_recv_queue( | |
| reason: Utf8Bytes::from_static("too many requests"), | ||
| }); | ||
| let on_message_after_close = move |client_id| { | ||
| log::warn!("client {client_id} sent message after close or error"); | ||
| log::debug!("client {client_id} sent message after close or error"); | ||
| }; | ||
|
|
||
| let max_incoming_queue_length = state.config.incoming_queue_length.get(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,6 +213,7 @@ impl async_cache::Fetcher<Arc<JwksValidator>> for KeyFetcher { | |
| // TODO: We should probably add debouncing to avoid spamming the logs. | ||
| // Alternatively we could add a backoff before retrying. | ||
| if let Err(e) = &key_or_error { | ||
| // TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers. | ||
| log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}"); | ||
|
Comment on lines
+216
to
217
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one I'm not 100% sure if we need to split up or count everything as |
||
| } | ||
| let keys = key_or_error?; | ||
|
|
@@ -265,6 +266,7 @@ impl TokenValidator for OidcTokenValidator { | |
| // TODO: We should probably add debouncing to avoid spamming the logs. | ||
| // Alternatively we could add a backoff before retrying. | ||
| if let Err(e) = &key_or_error { | ||
| // TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers. | ||
| log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}"); | ||
| } | ||
| let keys = key_or_error?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -679,6 +679,7 @@ impl InstanceCommon { | |
|
|
||
| match res { | ||
| Err(e) => { | ||
| // TODO: Review log level after migration/user errors can be distinguished from internal database failures. | ||
| log::warn!("Database update failed: {} @ {}", e, stdb.database_identity()); | ||
| system_logger.warn(&format!("Database update failed: {e}")); | ||
| let (_, tx_metrics, reducer) = stdb.rollback_mut_tx(tx); | ||
|
Comment on lines
+682
to
685
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another spot where it looks like real failures can be mixed in with user issues. |
||
|
|
@@ -1399,6 +1400,7 @@ impl InstanceCommon { | |
| match outcome { | ||
| Ok(outcome) => outcome, | ||
| Err(err) => { | ||
| // TODO: Review log level after guest view errors can be distinguished from materialization failures. | ||
| log::error!("Error materializing view `{view_name}`: {err:?}"); | ||
| ViewOutcome::Failed(format!("Error materializing view `{view_name}`: {err}")) | ||
|
Comment on lines
+1403
to
1405
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one looked similar as above but I'm not certain if it's true that it can be mixed here. |
||
| } | ||
|
|
||
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.
Same as other areas we might want to split this up so we can use
error!if there is a database failure.