From 6e6e54a8192a67ac53fae3d341757d9e59f71b81 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Tue, 12 Nov 2024 16:09:46 +0000 Subject: [PATCH] Log any errors that occur while getting canister status --- .../impl/src/jobs/topup_canisters.rs | 11 +++++++---- .../local_user_index/impl/src/jobs/topup_canisters.rs | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/canisters/local_group_index/impl/src/jobs/topup_canisters.rs b/backend/canisters/local_group_index/impl/src/jobs/topup_canisters.rs index 7baaaee0c9..e048e3314d 100644 --- a/backend/canisters/local_group_index/impl/src/jobs/topup_canisters.rs +++ b/backend/canisters/local_group_index/impl/src/jobs/topup_canisters.rs @@ -6,7 +6,7 @@ use ic_cdk_timers::TimerId; use std::cell::Cell; use std::collections::VecDeque; use std::time::Duration; -use tracing::info; +use tracing::{error, info}; use types::{CanisterId, Milliseconds}; use utils::canister_timers::run_now_then_interval; use utils::time::DAY_IN_MS; @@ -54,9 +54,12 @@ fn next(state: &mut RuntimeState) -> Option { } async fn run_async(canister_id: CanisterId) { - if let Ok((status,)) = ic_cdk::api::management_canister::main::canister_status(CanisterIdRecord { canister_id }).await { - if status.cycles < Nat::from(2u32) * status.settings.freezing_threshold { - top_up_canister(Some(canister_id)).await; + match ic_cdk::api::management_canister::main::canister_status(CanisterIdRecord { canister_id }).await { + Ok((status,)) => { + if status.cycles < Nat::from(2u32) * status.settings.freezing_threshold { + top_up_canister(Some(canister_id)).await; + } } + Err(error) => error!(%canister_id, ?error, "Error getting canister status"), } } diff --git a/backend/canisters/local_user_index/impl/src/jobs/topup_canisters.rs b/backend/canisters/local_user_index/impl/src/jobs/topup_canisters.rs index 01ea0fad25..51fec45b00 100644 --- a/backend/canisters/local_user_index/impl/src/jobs/topup_canisters.rs +++ b/backend/canisters/local_user_index/impl/src/jobs/topup_canisters.rs @@ -6,7 +6,7 @@ use ic_cdk_timers::TimerId; use std::cell::Cell; use std::collections::VecDeque; use std::time::Duration; -use tracing::info; +use tracing::{error, info}; use types::{Milliseconds, UserId}; use utils::canister_timers::run_now_then_interval; use utils::time::DAY_IN_MS; @@ -47,13 +47,16 @@ fn next(state: &mut RuntimeState) -> Option { } async fn run_async(user_id: UserId) { - if let Ok((status,)) = ic_cdk::api::management_canister::main::canister_status(CanisterIdRecord { + match ic_cdk::api::management_canister::main::canister_status(CanisterIdRecord { canister_id: user_id.into(), }) .await { - if status.cycles < Nat::from(2u32) * status.settings.freezing_threshold { - top_up_user(Some(user_id)).await; + Ok((status,)) => { + if status.cycles < Nat::from(2u32) * status.settings.freezing_threshold { + top_up_user(Some(user_id)).await; + } } + Err(error) => error!(%user_id, ?error, "Error getting canister status"), } }