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 BE3151FF0DD for ; Thu, 22 Oct 2026 18:44:29 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D49F2216AB; Thu, 22 Oct 2026 18:44:27 +0200 (CEST) From: Jonas Theisen To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v4 6/9] fix #7904: api: implement "disable" for {sync,verify,tape,GC} jobs Date: Thu, 22 Oct 2026 18:43:21 +0200 Message-ID: <20261022164343.353831-7-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261022164343.353831-1-j.theisen@proxmox.com> References: <20261022164343.353831-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: 1792687452128 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.115 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: SULSFEQUSSYGTX6W2WQSOMIR5BK2TVNO X-Message-ID-Hash: SULSFEQUSSYGTX6W2WQSOMIR5BK2TVNO 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 users to disable jobs without having to remove the schedule this patch introduces the "disable" parameter. This can also be used to create jobs which are supposed to be run only manually, since with the "disable" parameter set to true, no schedule is required. The create endpoint for the respective jobs now also raises a parameter error if no schedule is set and the job is not disabled. Updates are not checked, so that unrelated config updates of existing jobs without a schedule are not prevented. The value is inserted into the job config and honored by the scheduler by skipping disabled jobs altogether. For GC jobs the value is inserted into the datastore config. If the value is not present in a job config it is assumed the job is to be enabled for backwards compatibility and to reduce config-bloat. Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=7904 Signed-off-by: Jonas Theisen --- src/api2/admin/datastore.rs | 1 + src/api2/config/datastore.rs | 9 +++++++++ src/api2/config/sync.rs | 18 +++++++++++++++++- src/api2/config/tape_backup_job.rs | 17 ++++++++++++++++- src/api2/config/verify.rs | 17 ++++++++++++++++- src/bin/proxmox-backup-proxy.rs | 16 ++++++++++++++++ 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index b19a3fed7..236f081ea 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1263,6 +1263,7 @@ pub(crate) fn garbage_collection_status_unchecked( let mut info = GarbageCollectionJobStatus { store: store.clone(), schedule: store_config.gc_schedule, + disable: store_config.gc_disable, ..Default::default() }; diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index a8b003601..f3644149e 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -406,6 +406,8 @@ pub fn read_datastore( pub enum DeletableProperty { /// Delete the comment property. Comment, + /// Unset the disable flag. + GcDisable, /// Delete the garbage collection schedule. GcSchedule, /// Delete the gc-on-unmount property. @@ -493,6 +495,9 @@ pub fn update_datastore( DeletableProperty::Comment => { data.comment = None; } + DeletableProperty::GcDisable => { + data.gc_disable = false; + } DeletableProperty::GcSchedule => { data.gc_schedule = None; } @@ -571,6 +576,10 @@ pub fn update_datastore( data.gc_on_unmount = update.gc_on_unmount; } + if let Some(value) = update.gc_disable { + data.gc_disable = value; + } + macro_rules! prune_disabled { ($(($param:literal, $($member:tt)+)),+) => { $( diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs index beed6e7e3..b05fe8b5b 100644 --- a/src/api2/config/sync.rs +++ b/src/api2/config/sync.rs @@ -1,5 +1,5 @@ use ::serde::{Deserialize, Serialize}; -use anyhow::{Error, bail}; +use anyhow::{Error, bail, format_err}; use pbs_api_types::SyncDirection; use serde_json::Value; @@ -306,6 +306,13 @@ pub fn create_sync_job( } } + if !config.disable && config.schedule.is_none() { + param_bail!( + "schedule", + format_err!("job enabled but no schedule provided") + ); + } + let (mut section_config, _digest) = sync::config()?; if section_config.sections.contains_key(&config.id) { @@ -383,6 +390,8 @@ pub enum DeletableProperty { Owner, /// Delete the comment property. Comment, + /// Unset the disable flag. + Disable, /// Delete the job schedule. Schedule, /// Delete the remove-vanished flag. @@ -499,6 +508,9 @@ pub fn update_sync_job( DeletableProperty::Comment => { data.comment = None; } + DeletableProperty::Disable => { + data.disable = false; + } DeletableProperty::Schedule => { data.schedule = None; } @@ -702,6 +714,9 @@ pub fn update_sync_job( if update.schedule.is_some() { data.schedule = update.schedule; } + if let Some(value) = update.disable { + data.disable = value; + } if update.remove_vanished.is_some() { data.remove_vanished = update.remove_vanished; } @@ -847,6 +862,7 @@ acl:1:/remote/remote1/remotestore1:write@pbs:RemoteSyncOperator max_depth: None, group_filter: None, schedule: None, + disable: false, limit: pbs_api_types::RateLimitConfig::default(), // no limit transfer_last: None, encrypted_only: None, diff --git a/src/api2/config/tape_backup_job.rs b/src/api2/config/tape_backup_job.rs index 4bfc7f871..4df1137da 100644 --- a/src/api2/config/tape_backup_job.rs +++ b/src/api2/config/tape_backup_job.rs @@ -1,5 +1,5 @@ use ::serde::{Deserialize, Serialize}; -use anyhow::Error; +use anyhow::{Error, format_err}; use serde_json::Value; use proxmox_router::{Permission, Router, RpcEnvironment, http_bail}; @@ -79,6 +79,13 @@ pub fn create_tape_backup_job( check_tape_backup_permission(&auth_id, &job.setup)?; + if !job.disable && job.schedule.is_none() { + param_bail!( + "schedule", + format_err!("job enabled but no schedule provided") + ); + } + let _lock = pbs_config::tape_job::lock()?; let (mut config, _digest) = pbs_config::tape_job::config()?; @@ -130,6 +137,8 @@ pub fn read_tape_backup_job( pub enum DeletableProperty { /// Delete the comment property. Comment, + /// Unset the disable flag. + Disable, /// Delete the job schedule. Schedule, /// Delete the eject-media property @@ -224,6 +233,9 @@ pub fn update_tape_backup_job( DeletableProperty::Comment => { data.comment = None; } + DeletableProperty::Disable => { + data.disable = false; + } DeletableProperty::GroupFilter => { data.setup.group_filter = None; } @@ -286,6 +298,9 @@ pub fn update_tape_backup_job( if update.schedule.is_some() { data.schedule = update.schedule; } + if let Some(value) = update.disable { + data.disable = value; + } if let Some(comment) = update.comment { let comment = comment.trim(); diff --git a/src/api2/config/verify.rs b/src/api2/config/verify.rs index 35be9b175..588d4abf2 100644 --- a/src/api2/config/verify.rs +++ b/src/api2/config/verify.rs @@ -1,5 +1,5 @@ use ::serde::{Deserialize, Serialize}; -use anyhow::Error; +use anyhow::{Error, format_err}; use serde_json::Value; use proxmox_router::{Permission, Router, RpcEnvironment, http_bail}; @@ -80,6 +80,13 @@ pub fn create_verification_job( user_info.check_privs(&auth_id, &config.acl_path(), PRIV_DATASTORE_VERIFY, false)?; + if !config.disable && config.schedule.is_none() { + param_bail!( + "schedule", + format_err!("job enabled but no schedule provided") + ); + } + let _lock = verify::lock_config()?; let (mut section_config, _digest) = verify::config()?; @@ -140,6 +147,8 @@ pub enum DeletableProperty { IgnoreVerified, /// Delete the comment property. Comment, + /// Unset the disable flag. + Disable, /// Delete the job schedule. Schedule, /// Delete outdated after property. @@ -220,6 +229,9 @@ pub fn update_verification_job( DeletableProperty::Comment => { data.comment = None; } + DeletableProperty::Disable => { + data.disable = false; + } DeletableProperty::Schedule => { data.schedule = None; } @@ -262,6 +274,9 @@ pub fn update_verification_job( if update.schedule.is_some() { data.schedule = update.schedule; } + if let Some(value) = update.disable { + data.disable = value; + } if let Some(ns) = update.ns { if !ns.is_root() { data.ns = Some(ns); diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index c66cffeb4..ce2629d0e 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -537,6 +537,10 @@ async fn schedule_datastore_garbage_collection() { } }; + if store_config.gc_disable { + continue; + } + let event_str = match store_config.gc_schedule { Some(event_str) => event_str, None => continue, @@ -689,6 +693,10 @@ async fn schedule_datastore_sync_jobs() { None => continue, }; + if job_config.disable { + continue; + } + let worker_type = "syncjob"; if check_schedule(worker_type, &event_str, &job_id) { let job = match Job::new(worker_type, &job_id) { @@ -725,6 +733,10 @@ async fn schedule_datastore_verify_jobs() { None => continue, }; + if job_config.disable { + continue; + } + let worker_type = "verificationjob"; let auth_id = Authid::root_auth_id().clone(); if check_schedule(worker_type, &event_str, &job_id) { @@ -761,6 +773,10 @@ async fn schedule_tape_backup_jobs() { None => continue, }; + if job_config.disable { + continue; + } + let worker_type = "tape-backup-job"; let auth_id = Authid::root_auth_id().clone(); if check_schedule(worker_type, &event_str, &job_id) { -- 2.47.3