From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9D9421FF0DD for ; Thu, 22 Oct 2026 18:44:10 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1350F21646; Thu, 22 Oct 2026 18:44:10 +0200 (CEST) From: Jonas Theisen To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup v4 3/9] server: schedules: add 'disable' parameter to compute_schedule_status() Date: Thu, 22 Oct 2026 18:43:18 +0200 Message-ID: <20261022164343.353831-4-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: 1792687442240 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.120 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: G7CUXO56Y7GI5MSV45WPY475QUVSVRT3 X-Message-ID-Hash: G7CUXO56Y7GI5MSV45WPY475QUVSVRT3 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 properly calculate the next_run for jobs the scheduler needs to know if the job is currently disabled. This commit adds the parameter to the function and sets the next_run property to None if the job is disabled. This is equivalent to no or an invalid schedule. All callers are adapted to pass the disable flag of their job. For prune jobs this replaces the manual reset of next_run for disabled jobs. Signed-off-by: Jonas Theisen --- src/api2/admin/datastore.rs | 8 ++++++-- src/api2/admin/prune.rs | 6 ++---- src/api2/admin/sync.rs | 3 ++- src/api2/admin/verify.rs | 7 ++++++- src/api2/tape/backup.rs | 7 ++++++- src/server/jobstate.rs | 4 +++- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index cfe976811..b19a3fed7 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1269,8 +1269,12 @@ pub(crate) fn garbage_collection_status_unchecked( let datastore = DataStore::lookup_datastore(lookup_with(&store, Operation::Read))?; let status_in_memory = datastore.last_gc_status(); - let computed_schedule: JobScheduleStatus = - compute_schedule_status("garbage_collection", &store, info.schedule.as_deref())?; + let computed_schedule: JobScheduleStatus = compute_schedule_status( + "garbage_collection", + &store, + info.schedule.as_deref(), + info.disable, + )?; if let Some(ref upid) = status_in_memory.upid { if let Some(endtime) = computed_schedule.last_run_endtime { diff --git a/src/api2/admin/prune.rs b/src/api2/admin/prune.rs index 0846d8893..eb57b0167 100644 --- a/src/api2/admin/prune.rs +++ b/src/api2/admin/prune.rs @@ -73,10 +73,8 @@ pub fn list_prune_jobs( let mut list = Vec::new(); for job in job_config_iter { - let mut status = compute_schedule_status("prunejob", &job.id, Some(&job.schedule))?; - if job.disable { - status.next_run = None; - } + let status = + compute_schedule_status("prunejob", &job.id, Some(&job.schedule), job.disable)?; list.push(PruneJobStatus { config: job, diff --git a/src/api2/admin/sync.rs b/src/api2/admin/sync.rs index 1799f51c0..9be86fbb0 100644 --- a/src/api2/admin/sync.rs +++ b/src/api2/admin/sync.rs @@ -112,7 +112,8 @@ pub fn list_config_sync_jobs( continue; } - let status = compute_schedule_status("syncjob", &job.id, job.schedule.as_deref())?; + let status = + compute_schedule_status("syncjob", &job.id, job.schedule.as_deref(), job.disable)?; list.push(SyncJobStatus { config: job, diff --git a/src/api2/admin/verify.rs b/src/api2/admin/verify.rs index 80659ebe2..a60a44f6f 100644 --- a/src/api2/admin/verify.rs +++ b/src/api2/admin/verify.rs @@ -73,7 +73,12 @@ pub fn list_verification_jobs( let mut list = Vec::new(); for job in job_config_iter { - let status = compute_schedule_status("verificationjob", &job.id, job.schedule.as_deref())?; + let status = compute_schedule_status( + "verificationjob", + &job.id, + job.schedule.as_deref(), + job.disable, + )?; list.push(VerificationJobStatus { config: job, diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs index c0a4ca65b..a92d032e1 100644 --- a/src/api2/tape/backup.rs +++ b/src/api2/tape/backup.rs @@ -81,7 +81,12 @@ pub fn list_tape_backup_jobs( continue; } - let status = compute_schedule_status("tape-backup-job", &job.id, job.schedule.as_deref())?; + let status = compute_schedule_status( + "tape-backup-job", + &job.id, + job.schedule.as_deref(), + job.disable, + )?; let next_run = status.next_run.unwrap_or(current_time); diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs index 7add06779..23134c60c 100644 --- a/src/server/jobstate.rs +++ b/src/server/jobstate.rs @@ -340,6 +340,7 @@ pub fn compute_schedule_status( jobtype: &str, jobname: &str, schedule: Option<&str>, + disable: bool, ) -> Result { let job_state = match JobState::load(jobtype, jobname) { Ok(job_state) => job_state, @@ -385,7 +386,8 @@ pub fn compute_schedule_status( ..Default::default() }; - if let Some(schedule) = schedule { + // a disabled job has no next run, just like a job without a schedule + if let Some(schedule) = schedule.filter(|_| !disable) { if let Ok(event) = schedule.parse::() { // ignore errors status.next_run = event.compute_next_event(last).unwrap_or(None); -- 2.47.3