From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4EEBD1FF136 for ; Mon, 23 Mar 2026 13:55:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3347A172C8; Mon, 23 Mar 2026 13:55:26 +0100 (CET) Date: Mon, 23 Mar 2026 13:55:16 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= Subject: Re: [PATCH proxmox-backup v2 1/3] api: move statefile loading into compute_schedule_status To: Christian Ebner , Michael =?iso-8859-1?b?S/ZwcGw=?= , pbs-devel@lists.proxmox.com References: <20260319110318.70346-1-m.koeppl@proxmox.com> <20260319110318.70346-2-m.koeppl@proxmox.com> <75768b61-8ff5-4e0a-b7e4-3b5fafbdd1c9@proxmox.com> <3b18d413-11f2-4179-aabd-4e9f000924ea@proxmox.com> In-Reply-To: <3b18d413-11f2-4179-aabd-4e9f000924ea@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1774270312.uf8ttrfndd.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774270473271 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 2Q3RYEMATVJQVI46PLTZRT3UJLQMAC3X X-Message-ID-Hash: 2Q3RYEMATVJQVI46PLTZRT3UJLQMAC3X X-MailFrom: f.gruenbichler@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On March 19, 2026 4:27 pm, Christian Ebner wrote: > On 3/19/26 3:47 PM, Michael K=C3=B6ppl wrote: >> On Thu Mar 19, 2026 at 12:24 PM CET, Christian Ebner wrote: >>> one comment inline. >>> >>> On 3/19/26 12:03 PM, Michael K=C3=B6ppl wrote: >>>> Centralize loading of the job statefiles in compute_schedule_status, >>>> reducing code duplication across the job management API endpoints. >>>> >>>> Signed-off-by: Michael K=C3=B6ppl >>>> --- >>>> src/api2/admin/datastore.rs | 13 +++---------- >>>> src/api2/admin/prune.rs | 9 +++------ >>>> src/api2/admin/sync.rs | 9 +++------ >>>> src/api2/admin/verify.rs | 9 +++------ >>>> src/api2/tape/backup.rs | 9 +++------ >>>> src/server/jobstate.rs | 8 ++++++-- >>>> 6 files changed, 21 insertions(+), 36 deletions(-) >>>> >>>> diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs >>>> index cca340553..4018e0301 100644 >>>> --- a/src/api2/admin/datastore.rs >>>> +++ b/src/api2/admin/datastore.rs >>>> @@ -70,7 +70,7 @@ use proxmox_rest_server::{formatter, worker_is_activ= e, WorkerTask}; >>>> use crate::api2::backup::optional_ns_param; >>>> use crate::api2::node::rrd::create_value_from_rrd; >>>> use crate::backup::{check_ns_privs_full, ListAccessibleBackupGroups= , VerifyWorker, NS_PRIVS_OK}; >>>> -use crate::server::jobstate::{compute_schedule_status, Job, JobState}= ; >>>> +use crate::server::jobstate::{compute_schedule_status, Job}; >>>> use crate::tools::{backup_info_to_snapshot_list_item, get_all_snaps= hot_files, read_backup_index}; >>>> =20 >>>> // helper to unify common sequence of checks: >>>> @@ -1167,19 +1167,12 @@ pub fn garbage_collection_status( >>>> =20 >>>> let datastore =3D DataStore::lookup_datastore(&store, Operation= ::Read)?; >>>> let status_in_memory =3D datastore.last_gc_status(); >>>> - let state_file =3D JobState::load("garbage_collection", &store) >>>> - .map_err(|err| log::error!("could not open GC statefile for {= store}: {err}")) >>>> - .ok(); >>>> =20 >>>> let mut last =3D proxmox_time::epoch_i64(); >>>> =20 >>>> if let Some(ref upid) =3D status_in_memory.upid { >>>> - let mut computed_schedule: JobScheduleStatus =3D JobScheduleS= tatus::default(); >>>> - if let Some(state) =3D state_file { >>>> - if let Ok(cs) =3D compute_schedule_status(&state, Some(up= id)) { >>>> - computed_schedule =3D cs; >>>> - } >>>> - } >>>> + let computed_schedule: JobScheduleStatus =3D >>>> + compute_schedule_status("garbage_collection", &store, Som= e(upid))?; >>> >>> This alters behavior as now it is never tried to load the state file if >>> status_in_memory.upid is None, so there is no error logged. >>> >>> So this must be expanded by an else branch where the loading is >>> attempted also for that case and the potential error logged. >>=20 >> Missed that while refactoring, sorry for the oversight. Also noticed >> that there is an additional change in behavior regarding the handling of >> any *other* error that might occur in compute_schedule_status because >> previously, we would use basically ignore any error and return the >> default status here, e.g. if the UPID could not be parsed for a started >> job. To match this behavior, I could just do >>=20 >> let computed_schedule: JobScheduleStatus =3D >> compute_schedule_status("garbage_collection", &store, Some(upid= )) >> .unwrap_or_else(|_| JobScheduleStatus::default()); >>=20 >> But the question is if the behavior here *should* differ from all other >> endpoints if the UPID could not be parsed? Because everywhere else we'd >> still return an error in that case. >=20 > True: this was introduced with commit fe1d34d2e ("api: garbage collect=20 > job status") and then adapted with commit 3ae21d87c ("GC: flatten=20 > existing status into job status"). So I guess this is related to the=20 > mentioned renaming. >=20 > Maybe Fabian can give us a clue? If there is a sensible way to handle compute_schedule_status failing (AFAICT, currently that only triggers if the UPID can't be parsed), we should do it consistently across the board - the same is true if that is not possible ;) maybe we should introduce another JobState variant that is not persisted ever, but used as a placeholder for partially-invalid entries? we already do quite a bit of mangling of other invalid data there anyway..