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 5/9] api: prune job: align prune job schedule to other jobs
Date: Thu, 22 Oct 2026 18:43:20 +0200	[thread overview]
Message-ID: <20261022164343.353831-6-j.theisen@proxmox.com> (raw)
In-Reply-To: <20261022164343.353831-1-j.theisen@proxmox.com>

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<String> 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 <j.theisen@proxmox.com>
---
 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 e7028480c..a8b003601 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





  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 ` [PATCH proxmox-backup v4 3/9] server: schedules: add 'disable' parameter to compute_schedule_status() Jonas Theisen
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 ` Jonas Theisen [this message]
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-6-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