all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Jonas Theisen <j.theisen@proxmox.com>
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	[thread overview]
Message-ID: <20261022164343.353831-4-j.theisen@proxmox.com> (raw)
In-Reply-To: <20261022164343.353831-1-j.theisen@proxmox.com>

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 <j.theisen@proxmox.com>
---
 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<JobScheduleStatus, Error> {
     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::<CalendarEvent>() {
             // ignore errors
             status.next_run = event.compute_next_event(last).unwrap_or(None);
-- 
2.47.3





  parent reply	other threads:[~2026-10-22 16:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 16:43 [PATCH proxmox{,-backup} v4 0/9] fix #7904: Implement Enable checkboxes for all jobs Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox v4 1/9] pbs-api-types: add 'disable' to {sync,verify,tape,gc} job schema and datastore config Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox v4 2/9] pbs-api-types: prune job: make schedule optional Jonas Theisen
2026-10-22 16:43 ` Jonas Theisen [this message]
2026-10-22 16:43 ` [PATCH proxmox-backup v4 4/9] ui: prune job: align prune edit window to other "Enable" checkboxes Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox-backup v4 5/9] api: prune job: align prune job schedule to other jobs Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox-backup v4 6/9] fix #7904: api: implement "disable" for {sync,verify,tape,GC} jobs Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox-backup v4 7/9] fix #7904: ui: add "Enable" checkbox to {sync,verify,tape,GC} job edit Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox-backup v4 8/9] ui: job overview: show "Disabled" as schedule of disabled jobs Jonas Theisen
2026-10-22 16:43 ` [PATCH proxmox-backup v4 9/9] ui: calendar-event: hide clear button if a schedule is required Jonas Theisen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261022164343.353831-4-j.theisen@proxmox.com \
    --to=j.theisen@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal