From b0728103b6b20fbf858fd46a86d51a35701a5cd0 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 22 Feb 2022 10:26:59 +0100 Subject: [PATCH] bin: daily-update: make single checks/updates fail gracefully avoid that the acme renewal is skipped due to bailing out earlier from a subscription or apt update error. Signed-off-by: Thomas Lamprecht --- src/bin/proxmox-daily-update.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/bin/proxmox-daily-update.rs b/src/bin/proxmox-daily-update.rs index 8ecd9d3c..12c5974d 100644 --- a/src/bin/proxmox-daily-update.rs +++ b/src/bin/proxmox-daily-update.rs @@ -25,10 +25,14 @@ async fn do_update(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { let param = json!({}); let method = &api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION; - let _res = match method.handler { - ApiHandler::Sync(handler) => (handler)(param, method, rpcenv)?, + match method.handler { + ApiHandler::Sync(handler) => { + if let Err(err) = (handler)(param, method, rpcenv) { + eprintln!("Error checking subscription - {}", err); + } + } _ => unreachable!(), - }; + } let notify = match subscription::read_subscription() { Ok(Some(subscription)) => subscription.status == subscription::SubscriptionStatus::ACTIVE, @@ -43,11 +47,15 @@ async fn do_update(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { "notify": notify, }); let method = &api2::node::apt::API_METHOD_APT_UPDATE_DATABASE; - let upid = match method.handler { - ApiHandler::Sync(handler) => (handler)(param, method, rpcenv)?, + match method.handler { + ApiHandler::Sync(handler) => match (handler)(param, method, rpcenv) { + Err(err) => { + eprintln!("Error triggering apt database update - {}", err); + } + Ok(upid) => wait_for_local_worker(upid.as_str().unwrap()).await?, + }, _ => unreachable!(), }; - wait_for_local_worker(upid.as_str().unwrap()).await?; match check_acme_certificates(rpcenv).await { Ok(()) => (),