public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH proxmox-offline-mirror] Add possibility to create named snapshots
Date: Fri, 09 May 2025 09:33:38 +0200	[thread overview]
Message-ID: <1746775510.z21powyuv4.astroid@yuna.none> (raw)
In-Reply-To: <999465b4-a40f-4c0f-98b8-6a272e2ee609@proxmox.com>

On May 8, 2025 5:17 pm, Laurențiu Leahu-Vlăducu wrote:
> Thanks for your feedback! Some answers inline.
> 
> On 08.05.25 11:14, Fabian Grünbichler wrote:
>> On May 6, 2025 11:09 am, Laurențiu Leahu-Vlăducu wrote:
>>> @@ -807,6 +801,42 @@ pub fn create_snapshot(
>>>           total: Progress::new(),
>>>       };
>>>   
>>> +    let mut config: ParsedMirrorConfig = config.try_into()?;
>>> +    config.auth = auth;
>>> +
>>> +    let snapshot_relative_path = snapshot.to_string();
>>> +    let snapshot_relative_path = Path::new(&snapshot_relative_path);
>>> +    let snapshot_absolute_path = config.pool.get_path(snapshot_relative_path);
>>> +
>>> +    if snapshot_absolute_path.is_ok_and(|path| path.exists()) {
>>> +        if dry_run {
>>> +            let msg = "WARNING: snapshot {snapshot} already exists! Continuing due to dry run...";
>>> +            eprintln!("{msg}");
>>> +            progress.warnings.push(msg.into());
>>> +        } else {
>>> +            bail!("Snapshot {snapshot} already exists!");
>>> +        }
>>> +    }
>>> +
>>> +    let lockfile_path = config
>>> +        .pool
>>> +        .get_path(Path::new(&format!(".{snapshot}.lock")));
>> 
>> what does this new lock protect against? what is its scope? note that a
>> pool can be shared between mirrors..
> 
> Until now, it was only possible to create snapshots containing a 
> timestamp, meaning that unless you were so fast to create multiple 
> snapshots per second, it was impossible to begin creating two snapshots 
> at once. However, you can now theoretically try to create two snapshots 
> with the same name at the same time (e.g. over two SSH connections) - 
> that is, creating a second snapshot before the first one finished 
> creating. The lockfile protects against such an issue.

shouldn't that be covered by checking for/creating the .tmp path while
holding the regular pool lock?

if we switch to "label" operations, then the modifying operations for
those could just be implemented on the lock guard like we do for the
rest, and all this is moot anyway ;)

but maybe we should add the creation of the `prefix` dir to those
operations as well, including a check for it not already existing? right
now it is implicitly created by link_file_do when fetching the release
file..


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

      reply	other threads:[~2025-05-09  7:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06  9:09 Laurențiu Leahu-Vlăducu
2025-05-08  9:14 ` Fabian Grünbichler
2025-05-08 15:17   ` Laurențiu Leahu-Vlăducu
2025-05-09  7:33     ` Fabian Grünbichler [this message]

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=1746775510.z21powyuv4.astroid@yuna.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-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