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 v3 04/10] api: prune job: align prune job schedule to other jobs
Date: Fri,  9 Oct 2026 16:54:35 +0200	[thread overview]
Message-ID: <20261009145445.282494-2-j.theisen@proxmox.com> (raw)
In-Reply-To: <20261009145445.282494-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 0846d8893..784b0ac6f 100644
--- a/src/api2/admin/prune.rs
+++ b/src/api2/admin/prune.rs
@@ -73,7 +73,7 @@ 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))?;
+        let mut status = compute_schedule_status("prunejob", &job.id, job.schedule.as_deref())?;
         if job.disable {
             status.next_run = None;
         }
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..3186fad64 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!("no schedule provided but job also not disabled")
+        );
+    }
+
     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 = 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





  reply	other threads:[~2026-10-09 14:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:54 [PATCH proxmox-backup v3 03/10] ui: prune job: align prune edit window to other "Enable" checkboxes Jonas Theisen
2026-10-09 14:54 ` Jonas Theisen [this message]
2026-10-09 14:54 ` [PATCH proxmox-backup v3 05/10] fix #7904: api: implement "disable" for {sync,verify,tape,GC} jobs Jonas Theisen
2026-10-09 14:54 ` [PATCH proxmox-backup v3 06/10] fix #7904: ui: job edit: introduce "Enable" checkbox " Jonas Theisen
2026-10-09 14:54 ` [PATCH proxmox-backup v3 07/10] ui: improve visibility of disabled {sync,verify,tape,GC,prune} jobs on the overview page Jonas Theisen
2026-10-09 14:54 ` [PATCH proxmox-backup v3 08/10] ui: calendar-event: remove clear button from calendar selector Jonas Theisen
2026-10-09 14:54 ` [PATCH proxmox-backup v3 09/10] api: create datastore: allow creation without prune job Jonas Theisen
2026-10-09 14:54 ` [PATCH proxmox-backup v3 10/10] ui: create datastore: add enable checkboxes for {GC, prune} 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=20261009145445.282494-2-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