public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v2 2/3] fix #7400: api: gracefully handle corrupted job statefiles
Date: Thu, 19 Mar 2026 12:03:17 +0100	[thread overview]
Message-ID: <20260319110318.70346-3-m.koeppl@proxmox.com> (raw)
In-Reply-To: <20260319110318.70346-1-m.koeppl@proxmox.com>

Previously, if a job statefile was empty or corrupted (e.g. due to an
I/O error or an abrupt shutdown), the JobStatus::load method would
return an error that would be propagated up, causing the endpoint to
return an error to the user, meaning users would not see any of their
jobs if a single job had a corrupted statefile.

Instead, handle the error explicitly, logging an error message and
returning a default JobScheduleStatus such that jobs lists can still be
fetched, displaying the affected job as configured but simply missing
its last run status.

Signed-off-by: Michael Köppl <m.koeppl@proxmox.com>
---
 src/server/jobstate.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/server/jobstate.rs b/src/server/jobstate.rs
index cfb0b8945..638beac3e 100644
--- a/src/server/jobstate.rs
+++ b/src/server/jobstate.rs
@@ -305,8 +305,17 @@ pub fn compute_schedule_status(
     jobname: &str,
     schedule: Option<&str>,
 ) -> Result<JobScheduleStatus, Error> {
-    let job_state = JobState::load(jobtype, jobname)
-        .map_err(|err| format_err!("could not open statefile for {}: {}", jobname, err))?;
+    let job_state = match JobState::load(jobtype, jobname) {
+        Ok(job_state) => job_state,
+        Err(err) => {
+            log::error!(
+                "could not open statefile for {}: {} - falling back to default job schedule status",
+                jobname,
+                err
+            );
+            return Ok(JobScheduleStatus::default());
+        }
+    };
 
     let (upid, endtime, state, last) = match job_state {
         JobState::Created { time } => (None, None, None, time),
-- 
2.47.3





  parent reply	other threads:[~2026-03-19 11:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 11:03 [PATCH proxmox-backup v2 0/3] fix #7400: improve handling of " Michael Köppl
2026-03-19 11:03 ` [PATCH proxmox-backup v2 1/3] api: move statefile loading into compute_schedule_status Michael Köppl
2026-03-19 11:24   ` Christian Ebner
2026-03-19 14:47     ` Michael Köppl
2026-03-19 15:27       ` Christian Ebner
2026-03-19 11:03 ` Michael Köppl [this message]
2026-03-19 11:23   ` [PATCH proxmox-backup v2 2/3] fix #7400: api: gracefully handle corrupted job statefiles Christian Ebner
2026-03-19 11:03 ` [PATCH proxmox-backup v2 3/3] fix #7400: proxy: self-heal " Michael Köppl

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=20260319110318.70346-3-m.koeppl@proxmox.com \
    --to=m.koeppl@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal