public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox-backup v4 1/4] snapshot: add helper function to retrieve verify_state
Date: Fri, 22 Nov 2024 10:02:44 +0100	[thread overview]
Message-ID: <2pz4wpna4u4fkvtdpblj4xj62o4n746zbnsfqepw76jyphmp6d@djir34ghshw5> (raw)
In-Reply-To: <2086615808.8058.1732216671890@webmail.proxmox.com>

On 21.11.2024 20:17, Fabian Grünbichler wrote:
>> Gabriel Goller <g.goller@proxmox.com> hat am 21.11.2024 14:35 CET geschrieben:
>> +
>> +    /// Load the verify state from the manifest.
>> +    pub fn verify_state(&self) -> Result<Option<VerifyState>, anyhow::Error> {
>> +        let manifest = self.load_manifest()?;
>> +        Ok(manifest
>> +            .0
>> +            .verify_state()
>> +            .ok()
>> +            .flatten()
>> +            .map(|svs| svs.state))
>
>this still looks slightly wrong to me - if verify_state() returns an error, it's mapped to None (by the call to `ok()`), which would hide an inner parse error for the verification state?
>
>I think the following should be correctly bubble up errors when loading the manifest or when parsing the contained verify state while returning Ok(None) if no state is contained in the manifest:
>
>Ok(self.load_manifest()?.0.verify_state()?.map(|svs| svs.state))

I agree. I was somehow fixed on the load_manifest error always being the
outer one, but tbh it doesn't matter.

>
>> +    }
>>  }
>>
>> @@ -159,13 +159,12 @@ fn upgrade_to_backup_protocol(
>>              let info = backup_group.last_backup(true).unwrap_or(None);
>>              if let Some(info) = info {
>>                  let (manifest, _) = info.backup_dir.load_manifest()?;
>> -                let verify = manifest.unprotected["verify_state"].clone();
>> -                match serde_json::from_value::<SnapshotVerifyState>(verify) {
>> -                    Ok(verify) => match verify.state {
>> +                match manifest.verify_state() {
>> +                    Ok(Some(verify)) => match verify.state {
>>                          VerifyState::Ok => Some(info),
>>                          VerifyState::Failed => None,
>>                      },
>> -                    Err(_) => {
>> +                    Ok(None) | Err(_) => {
>>                          // no verify state found, treat as valid
>
>this as well, although it might make sense to log this here as well (pre-existing)

You mean separating the Ok(None) and Err(_) arm and `warn()` on the
Err(_) one?

>>                          Some(info)
>>                      }
>> diff --git a/src/backup/verify.rs b/src/backup/verify.rs
>> index 6ef7e8eb3ebb..20c605c4dde6 100644
>> --- a/src/backup/verify.rs
>> +++ b/src/backup/verify.rs
>> @@ -553,10 +553,9 @@ pub fn verify_filter(
>>          return true;
>>      }
>>
>> -    let raw_verify_state = manifest.unprotected["verify_state"].clone();
>> -    match serde_json::from_value::<SnapshotVerifyState>(raw_verify_state) {
>> -        Err(_) => true, // no last verification, always include
>> -        Ok(last_verify) => {
>> +    match manifest.verify_state() {
>> +        Ok(None) | Err(_) => true, // no last verification, always include
>
>same here! I think/hope the Err path for these should only trigger when somebody messes up manifests, but..

Yep.



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

  reply	other threads:[~2024-11-22  9:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 13:35 [pbs-devel] [PATCH proxmox-backup v4 0/4] fix #3786: resync corrupt chunks in sync-job Gabriel Goller
2024-11-21 13:35 ` [pbs-devel] [PATCH proxmox-backup v4 1/4] snapshot: add helper function to retrieve verify_state Gabriel Goller
2024-11-21 19:17   ` Fabian Grünbichler
2024-11-22  9:02     ` Gabriel Goller [this message]
2024-11-22  9:08       ` Fabian Grünbichler
2024-11-21 13:35 ` [pbs-devel] [PATCH proxmox-backup v4 2/4] fix #3786: api: add resync-corrupt option to sync jobs Gabriel Goller
2024-11-21 13:35 ` [pbs-devel] [PATCH proxmox-backup v4 3/4] fix #3786: ui/cli: add resync-corrupt option on sync-jobs Gabriel Goller
2024-11-21 13:35 ` [pbs-devel] [PATCH proxmox-backup v4 4/4] fix #3786: docs: add resync-corrupt option to sync-job Gabriel Goller
2024-11-21 19:21 ` [pbs-devel] [PATCH proxmox-backup v4 0/4] fix #3786: resync corrupt chunks in sync-job Fabian Grünbichler
2024-11-22  9:39   ` Gabriel Goller

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=2pz4wpna4u4fkvtdpblj4xj62o4n746zbnsfqepw76jyphmp6d@djir34ghshw5 \
    --to=g.goller@proxmox.com \
    --cc=f.gruenbichler@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