From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 56739BA0CE for ; Wed, 13 Dec 2023 16:38:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 24828C7F6 for ; Wed, 13 Dec 2023 16:38:31 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 13 Dec 2023 16:38:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C27D2472DF for ; Wed, 13 Dec 2023 16:38:29 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 13 Dec 2023 16:38:19 +0100 Message-Id: <20231213153819.391392-9-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231213153819.391392-1-c.ebner@proxmox.com> References: <20231213153819.391392-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.055 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [RFC proxmox-backup 8/8] proxy: add sanity check task to scheduler X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2023 15:38:31 -0000 Execute configured sanity check tasks based on their configured time schedule. Signed-off-by: Christian Ebner --- src/bin/proxmox-backup-proxy.rs | 41 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 9c49026b..8efa0655 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -44,7 +44,7 @@ use proxmox_time::CalendarEvent; use pbs_api_types::{ Authid, DataStoreConfig, Operation, PruneJobConfig, SyncJobConfig, TapeBackupJobConfig, - VerificationJobConfig, + VerificationJobConfig, SanityCheckJobConfig, }; use proxmox_rest_server::daemon; @@ -60,6 +60,7 @@ use proxmox_backup::api2::pull::do_sync_job; use proxmox_backup::api2::tape::backup::do_tape_backup_job; use proxmox_backup::server::do_prune_job; use proxmox_backup::server::do_verification_job; +use proxmox_backup::server::do_sanity_check_job; fn main() -> Result<(), Error> { pbs_tools::setup_libc_malloc_opts(); @@ -454,6 +455,7 @@ async fn schedule_tasks() -> Result<(), Error> { schedule_datastore_verify_jobs().await; schedule_tape_backup_jobs().await; schedule_task_log_rotate().await; + schedule_task_sanity_check_jobs().await; Ok(()) } @@ -825,6 +827,43 @@ async fn schedule_task_log_rotate() { } } +async fn schedule_task_sanity_check_jobs() { + let config = match pbs_config::sanity_check::config() { + Err(err) => { + eprintln!("unable to read sanity check job config - {err}"); + return; + } + Ok((config, _digest)) => config, + }; + for (job_id, (_, job_config)) in config.sections { + let job_config: SanityCheckJobConfig = match serde_json::from_value(job_config) { + Ok(c) => c, + Err(err) => { + eprintln!("sanity check job config from_value failed - {err}"); + continue; + } + }; + + let worker_type = "sanitycheckjob"; + let auth_id = Authid::root_auth_id().clone(); + if check_schedule(worker_type, &job_config.schedule, &job_id) { + let job = match Job::new(worker_type, &job_id) { + Ok(job) => job, + Err(_) => continue, // could not get lock + }; + if let Err(err) = do_sanity_check_job( + job, + job_config.options, + &auth_id, + Some(job_config.schedule), + ) { + eprintln!("unable to start sanity check job {job_id} - {err}"); + } + }; + } +} + + async fn command_reopen_access_logfiles() -> Result<(), Error> { // only care about the most recent daemon instance for each, proxy & api, as other older ones // should not respond to new requests anyway, but only finish their current one and then exit. -- 2.39.2