public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
@ 2023-03-21 17:03 Friedrich Weber
  2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
  2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
  0 siblings, 2 replies; 6+ messages in thread
From: Friedrich Weber @ 2023-03-21 17:03 UTC (permalink / raw)
  To: pve-devel

This prevents strange interactions in case the same content directory
is used for multiple content types.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 I guess technically this is a breaking change, as users may have an
 iso+vztmpl storage that symlinks 'templates/iso' to 'templates/cache',
 which would now throw an error.

 PVE/Storage/Plugin.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index c323085..3c9a179 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -3,6 +3,7 @@ package PVE::Storage::Plugin;
 use strict;
 use warnings;
 
+use Cwd qw(abs_path);
 use Encode qw(decode);
 use Fcntl ':mode';
 use File::chdir;
@@ -1362,6 +1363,16 @@ sub activate_storage {
 	"directory '$path' does not exist or is unreachable\n";
     }
 
+    # check that content dirs are pairwise inequal
+    my $resolved_subdirs = {};
+    if (defined($scfg->{content})) {
+	foreach my $vtype (keys $scfg->{content}->%*) {
+	    my $abs_subdir = abs_path($class->get_subdir($scfg, $vtype));
+	    die "storage '$storeid' uses directory $abs_subdir for multiple content types\n"
+		if defined($resolved_subdirs->{$abs_subdir});
+	    $resolved_subdirs->{$abs_subdir} = 1;
+	}
+    }
 
     return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] applied: [RFC storage] content-dirs: check that all content dirs are pairwise inequal
  2023-03-21 17:03 [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal Friedrich Weber
@ 2023-06-06 15:28 ` Thomas Lamprecht
  2023-06-07  7:46   ` Friedrich Weber
  2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Lamprecht @ 2023-06-06 15:28 UTC (permalink / raw)
  To: Proxmox VE development discussion, Friedrich Weber

Am 21/03/2023 um 18:03 schrieb Friedrich Weber:
> This prevents strange interactions in case the same content directory
> is used for multiple content types.
> 
> Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
> ---
>  I guess technically this is a breaking change, as users may have an
>  iso+vztmpl storage that symlinks 'templates/iso' to 'templates/cache',
>  which would now throw an error.

Well, then lets apply this for upcoming 8, maybe you can add a note to
our breaking changes list so that users are aware.

Also, checking this upfront and erroring in pve7to8 checker script should
not be that hard and def. help some to avoid problems during/after the
upgrade.

> 
>  PVE/Storage/Plugin.pm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] applied: [RFC storage] content-dirs: check that all content dirs are pairwise inequal
  2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
@ 2023-06-07  7:46   ` Friedrich Weber
  0 siblings, 0 replies; 6+ messages in thread
From: Friedrich Weber @ 2023-06-07  7:46 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion

On 06/06/2023 17:28, Thomas Lamprecht wrote:
> Well, then lets apply this for upcoming 8, maybe you can add a note to
> our breaking changes list so that users are aware.

Done!

> Also, checking this upfront and erroring in pve7to8 checker script should
> not be that hard and def. help some to avoid problems during/after the
> upgrade.

Yes, sounds sensible. I'll prepare a patch.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
  2023-03-21 17:03 [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal Friedrich Weber
  2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
@ 2023-06-07 10:01 ` Fiona Ebner
  2023-06-07 10:18   ` Friedrich Weber
  1 sibling, 1 reply; 6+ messages in thread
From: Fiona Ebner @ 2023-06-07 10:01 UTC (permalink / raw)
  To: Proxmox VE development discussion, Friedrich Weber

Am 21.03.23 um 18:03 schrieb Friedrich Weber:
> This prevents strange interactions in case the same content directory
> is used for multiple content types.
> 

Should we also check in the create/update API calls for syntactic
duplicates and fail the call? E.g. I can successfully issue:
pvesh set /storage/foo --content-dirs backup=bar,iso=bar
and only get the error later during activation.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
  2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
@ 2023-06-07 10:18   ` Friedrich Weber
  2023-06-07 10:35     ` Thomas Lamprecht
  0 siblings, 1 reply; 6+ messages in thread
From: Friedrich Weber @ 2023-06-07 10:18 UTC (permalink / raw)
  To: Fiona Ebner, Proxmox VE development discussion

On 07/06/2023 12:01, Fiona Ebner wrote:
> Should we also check in the create/update API calls for syntactic
> duplicates and fail the call? E.g. I can successfully issue:
> pvesh set /storage/foo --content-dirs backup=bar,iso=bar
> and only get the error later during activation.

Not allowing users to configure `content-dirs` with syntactic duplicates
sounds good to me (it wouldn't catch situations involving symlinks, but
those require quite some manual hacking from the user's side anyway).

As this would be mostly a convenience feature, I'd send a patch after
next week if that's okay.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
  2023-06-07 10:18   ` Friedrich Weber
@ 2023-06-07 10:35     ` Thomas Lamprecht
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2023-06-07 10:35 UTC (permalink / raw)
  To: Proxmox VE development discussion, Friedrich Weber, Fiona Ebner

Am 07/06/2023 um 12:18 schrieb Friedrich Weber:
> On 07/06/2023 12:01, Fiona Ebner wrote:
>> Should we also check in the create/update API calls for syntactic
>> duplicates and fail the call? E.g. I can successfully issue:
>> pvesh set /storage/foo --content-dirs backup=bar,iso=bar
>> and only get the error later during activation.

Definitively a good idea (tbh. I thought it acted already that way there too) 

> Not allowing users to configure `content-dirs` with syntactic duplicates
> sounds good to me (it wouldn't catch situations involving symlinks, but
> those require quite some manual hacking from the user's side anyway).
> 
> As this would be mostly a convenience feature, I'd send a patch after
> next week if that's okay.
> 

Yeah that's fine.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-07 10:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 17:03 [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal Friedrich Weber
2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
2023-06-07  7:46   ` Friedrich Weber
2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
2023-06-07 10:18   ` Friedrich Weber
2023-06-07 10:35     ` Thomas Lamprecht

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