From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id ACB9C1FF0C0 for ; Wed, 04 Nov 2026 15:54:37 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0E32021471; Wed, 04 Nov 2026 15:54:35 +0100 (CET) From: Jonas Theisen To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v5 5/9] api: prune job: align prune job schedule to other jobs Date: Wed, 4 Nov 2026 15:53:31 +0100 Message-ID: <20261104145405.441861-6-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261104145405.441861-1-j.theisen@proxmox.com> References: <20261104145405.441861-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793804070761 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.102 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5CV5KACPESF4EEQSXL52CO3M47FEYXPR X-Message-ID-Hash: 5CV5KACPESF4EEQSXL52CO3M47FEYXPR X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To allow creation of prune jobs without a schedule the parameter needs to be optional and be able to handle no content. This is already the case for the schedule parameters of the other job types, so this patch aligns the prune job schedules by using an Option instead of a plain String. This patch also integrates the API check for disable = true if no schedule is provided. Signed-off-by: Jonas Theisen --- src/api2/admin/prune.rs | 2 +- src/api2/config/datastore.rs | 2 +- src/api2/config/prune.rs | 16 +++++++++++----- src/bin/proxmox-backup-proxy.rs | 9 +++++++-- src/bin/proxmox_backup_manager/migrate_config.rs | 2 +- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/api2/admin/prune.rs b/src/api2/admin/prune.rs index eb57b0167..2ecca2c60 100644 --- a/src/api2/admin/prune.rs +++ b/src/api2/admin/prune.rs @@ -74,7 +74,7 @@ pub fn list_prune_jobs( for job in job_config_iter { let status = - compute_schedule_status("prunejob", &job.id, Some(&job.schedule), job.disable)?; + compute_schedule_status("prunejob", &job.id, job.schedule.as_deref(), job.disable)?; list.push(PruneJobStatus { config: job, diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index dfce8ae50..4de4e3150 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -321,7 +321,7 @@ pub fn create_datastore( store: config.name.clone(), comment: None, disable: false, - schedule: schedule.clone(), + schedule: Some(schedule.clone()), options: PruneJobOptions { keep: config.keep.clone(), max_depth: None, diff --git a/src/api2/config/prune.rs b/src/api2/config/prune.rs index 91d2324f9..60b123589 100644 --- a/src/api2/config/prune.rs +++ b/src/api2/config/prune.rs @@ -1,4 +1,4 @@ -use anyhow::Error; +use anyhow::{Error, format_err}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -112,6 +112,13 @@ pub fn create_prune_job( user_info.check_privs(&auth_id, &config.acl_path(), PRIV_DATASTORE_MODIFY, true)?; + if !config.disable && config.schedule.is_none() { + param_bail!( + "schedule", + format_err!("job enabled but no schedule provided") + ); + } + do_create_prune_job(config) } @@ -284,10 +291,9 @@ pub fn update_prune_job( user_info.check_privs(&auth_id, &data.acl_path(), PRIV_DATASTORE_MODIFY, true)?; } - let mut schedule_changed = false; - if let Some(schedule) = update.schedule { - schedule_changed = data.schedule != schedule; - data.schedule = schedule; + let schedule_changed = update.schedule.is_some() && data.schedule != update.schedule; + if update.schedule.is_some() { + data.schedule = update.schedule; } if let Some(max_depth) = update.options.max_depth { diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 22abfdbdb..c66cffeb4 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -641,9 +641,14 @@ async fn schedule_datastore_prune_jobs() { continue; } + let event_str = match job_config.schedule { + Some(event_str) => event_str, + None => continue, + }; + let worker_type = "prunejob"; let auth_id = Authid::root_auth_id().clone(); - if check_schedule(worker_type, &job_config.schedule, &job_id) { + if check_schedule(worker_type, &event_str, &job_id) { let job = match Job::new(worker_type, &job_id) { Ok(job) => job, Err(_) => continue, // could not get lock @@ -653,7 +658,7 @@ async fn schedule_datastore_prune_jobs() { job_config.options, job_config.store, &auth_id, - Some(job_config.schedule), + Some(event_str), ) { eprintln!("unable to start datastore prune job {job_id} - {err}"); } diff --git a/src/bin/proxmox_backup_manager/migrate_config.rs b/src/bin/proxmox_backup_manager/migrate_config.rs index 69f908dc5..b48d53104 100644 --- a/src/bin/proxmox_backup_manager/migrate_config.rs +++ b/src/bin/proxmox_backup_manager/migrate_config.rs @@ -84,7 +84,7 @@ pub(crate) fn update_to_prune_jobs_config() -> Result<(), Error> { store: store.clone(), disable: false, comment: None, - schedule, + schedule: Some(schedule), options, }; -- 2.47.3