deprecate mkdir option for create-base-path and create-subdirs
The `mkdir` option has two meanings[0][1] which are split up in `create-path` and `create-sub-dirs`. The `create-base-path` option decides if the path to the storage is automatically created or not. The `create-subdirs` options decides if the default directory structure (dump, images, ...) at the storage location is created. The `mkdir` option is still working but will trigger a warning in the logs. As a side effect, this also fixes #3214 because the `create-base-path` option is now run after the `is_mountpoint` check in the `activate_storage` method in DirPlugin.pm. The 'mkpath' command has been moved into a new helper function that first determines if the conditions to create the path is true, called 'config_aware_base_mkdir'. [0] https://lists.proxmox.com/pipermail/pve-devel/2020-December/046575.html [1] https://lists.proxmox.com/pipermail/pve-devel/2020-December/046576.html Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
39d9fb2440
commit
7c242295c9
@ -1362,7 +1362,12 @@ sub activate_storage {
|
||||
"directory '$path' does not exist or is unreachable\n";
|
||||
}
|
||||
|
||||
warn "${storeid}: 'mkdir' option is deprecated. Use 'create-base-path' or 'create-subdirs' instead.\n"
|
||||
if defined($scfg->{mkdir});
|
||||
|
||||
return if defined($scfg->{'create-subdirs'}) && !$scfg->{'create-subdirs'};
|
||||
|
||||
# FIXME The mkdir option is deprecated. Remove with PVE 9?
|
||||
return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
|
||||
|
||||
if (defined($scfg->{content})) {
|
||||
@ -1698,4 +1703,19 @@ sub rename_volume {
|
||||
return "${storeid}:${base}${target_vmid}/${target_volname}";
|
||||
}
|
||||
|
||||
sub config_aware_base_mkdir {
|
||||
my ($class, $scfg, $path) = @_;
|
||||
|
||||
# FIXME the mkdir parameter is deprecated and create-base-path should be used
|
||||
my $mkpath = 0;
|
||||
if (!defined($scfg->{'create-base-path'}) && !defined($scfg->{mkdir})) {
|
||||
$mkpath = 1;
|
||||
} elsif (defined($scfg->{'create-base-path'}) && $scfg->{'create-base-path'}) {
|
||||
$mkpath = 1;
|
||||
} elsif ($scfg->{mkdir}) {
|
||||
$mkpath = 1;
|
||||
}
|
||||
mkpath $path if $mkpath;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user