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] api: gc status: pass schedule instead of UPID to schedule helper
Date: Thu, 22 Oct 2026 18:15:49 +0200	[thread overview]
Message-ID: <20261022161612.331793-1-j.theisen@proxmox.com> (raw)

Since the GC job status was introduced and then refactored in [1]
the last GC run's UPID has been passed as the schedule argument
of compute_schedule_status().
A UPID never parses as a calendar event, so the computed next run
was always None, and it was then recomputed from the GC schedule
in a separate step after the fact.

Pass the configured GC schedule instead and use the helper's result
directly. This drops the duplicated computation, and the next run
of GC jobs is now derived from the job state file in the same way as
for sync, verify, prune and tape backup jobs. Previously, the base
was the last run's end time from the in-memory GC status, or the
current time if there was none, which ignored the job state that
the proxy's scheduler relies on.

[1] https://lore.proxmox.com/pbs-devel/20260319110318.70346-2-m.koeppl@proxmox.com/

Signed-off-by: Jonas Theisen <j.theisen@proxmox.com>
---
 src/api2/admin/datastore.rs | 28 +++-------------------------
 1 file changed, 3 insertions(+), 25 deletions(-)

diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 3367fb2c1..cfe976811 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -29,7 +29,6 @@ use proxmox_rrd_api_types::{RrdMode, RrdTimeframe};
 use proxmox_schema::*;
 use proxmox_sortable_macro::sortable;
 use proxmox_sys::fs::{CreateOptions, file_read_firstline, file_read_optional_string};
-use proxmox_time::CalendarEvent;
 use proxmox_worker_task::WorkerTaskContext;
 
 use pxar::EntryKind;
@@ -1270,42 +1269,21 @@ 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 mut last = proxmox_time::epoch_i64();
-
-    let jobtype = "garbage_collection";
+    let computed_schedule: JobScheduleStatus =
+        compute_schedule_status("garbage_collection", &store, info.schedule.as_deref())?;
 
     if let Some(ref upid) = status_in_memory.upid {
-        let computed_schedule: JobScheduleStatus =
-            compute_schedule_status(jobtype, &store, Some(upid))?;
-
         if let Some(endtime) = computed_schedule.last_run_endtime {
-            last = endtime;
             if let Ok(parsed_upid) = upid.parse::<UPID>() {
                 info.duration = Some(endtime - parsed_upid.starttime);
             }
         }
 
-        info.next_run = computed_schedule.next_run;
         info.last_run_endtime = computed_schedule.last_run_endtime;
         info.last_run_state = computed_schedule.last_run_state;
-    } else if let Err(err) = JobState::load(jobtype, &store) {
-        log::error!("could not open statefile for {store}: {err}");
     }
 
-    info.next_run = info
-        .schedule
-        .as_ref()
-        .and_then(|s| {
-            s.parse::<CalendarEvent>()
-                .map_err(|err| log::error!("{err}"))
-                .ok()
-        })
-        .and_then(|e| {
-            e.compute_next_event(last)
-                .map_err(|err| log::error!("{err}"))
-                .ok()
-        })
-        .and_then(|ne| ne);
+    info.next_run = computed_schedule.next_run;
 
     info.status = status_in_memory;
 
-- 
2.47.3





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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261022161612.331793-1-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