[pbs-devel] [PATCH proxmox-backup 2/2] api: disks: directory: fail if mount unit already exists
Shannon Sterz
s.sterz at proxmox.com
Wed Nov 27 16:23:04 CET 2024
On Wed Nov 27, 2024 at 4:06 PM CET, Fiona Ebner wrote:
> Without this check, if a mount unit is present, but the file system is
> not mounted, it will just get overwritten. The unit might belong to an
> existing datastore.
>
> There already is a check against a duplicate datastore, but only after
> the mount unit is already overwritten and having the add-datastore
> flag present is not a precondition to trigger the issue.
>
> The check is done even if the newly created directory datastore is
> removable. While in that case, the mount unit is not overwritten, the
> conflict for the mount point is still present, so it is nice to fail
> early.
>
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
> src/api2/node/disks/directory.rs | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
> index 7bdf0111..d4690d45 100644
> --- a/src/api2/node/disks/directory.rs
> +++ b/src/api2/node/disks/directory.rs
> @@ -204,6 +204,11 @@ pub fn create_datastore_disk(
> }
> }
>
> + let (mount_unit_path, _) = datastore_mount_unit_path_info(&mount_point);
> + if std::path::PathBuf::from(&mount_unit_path).exists() {
> + bail!("systemd mount unit {mount_unit_path:?} already exists");
nit: relying on the `Debug` trait here to quote the string feels a bit..
hacky to me? maybe just:
```rs
bail!("systemd mount unit \"{mount_unit_path}\" already exists");
```
or use single quotes as we do elsewhere.
> + }
> +
> let upid_str = WorkerTask::new_thread(
> "dircreate",
> Some(name.clone()),
Otherwise:
Reviewed-by: Shannon Sterz <s.sterz at proxmox.com>
More information about the pbs-devel
mailing list