From d8aa2f664d01e3bfc2ba704b868fd553e0cbe24f Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Wed, 7 Jul 2021 12:22:50 +0200 Subject: [PATCH] pve6to7: storage content: ignore misconfigured unreferenced volumes If the same local storage is configured twice with content type separation, migration in PVE 6 would lead to the volumes being duplicated. As that would happen for every migration, such an issue would likely be noticed already, and in PVE 7 such configuration is not problematic for migration anymore. Also, misconfigured unreferenced volumes are not an issue with respect to the upgrade itself, just drop the check. It's not necessary to scan storages with either 'images' or 'rootdir' anymore, as only the log_info() remains. Signed-off-by: Fabian Ebner Signed-off-by: Thomas Lamprecht --- PVE/CLI/pve6to7.pm | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/PVE/CLI/pve6to7.pm b/PVE/CLI/pve6to7.pm index e0d7ac13..fb928a9c 100644 --- a/PVE/CLI/pve6to7.pm +++ b/PVE/CLI/pve6to7.pm @@ -717,15 +717,11 @@ sub check_node_and_guest_configurations { sub check_storage_content { log_info("Checking storage content type configuration.."); - my $found_referenced; - my $found_unreferenced; + my $found; my $pass = 1; my $storage_cfg = PVE::Storage::config(); - my $potentially_affected = {}; - my $referenced_volids = {}; - for my $storeid (sort keys $storage_cfg->{ids}->%*) { my $scfg = $storage_cfg->{ids}->{$storeid}; @@ -740,7 +736,8 @@ sub check_storage_content { delete $scfg->{content}->{none}; # scan for guest images below } - next if $scfg->{content}->{images} && $scfg->{content}->{rootdir}; + next if $scfg->{content}->{images}; + next if $scfg->{content}->{rootdir}; # Skip 'iscsi(direct)' (and foreign plugins with potentially similiar behavior) with 'none', # because that means "use LUNs directly" and vdisk_list() in PVE 6.x still lists those. @@ -761,12 +758,8 @@ sub check_storage_content { } my @volids = map { $_->{volid} } $res->{$storeid}->@*; - for my $volid (@volids) { - $potentially_affected->{$volid} = 1; - } - my $number = scalar(@volids); - if ($number > 0 && !$scfg->{content}->{images} && !$scfg->{content}->{rootdir}) { + if ($number > 0) { log_info("storage '$storeid' - neither content type 'images' nor 'rootdir' configured" .", but found $number guest volume(s)"); } @@ -775,8 +768,6 @@ sub check_storage_content { my $check_volid = sub { my ($volid, $vmid, $vmtype, $reference) = @_; - $referenced_volids->{$volid} = 1 if $reference ne 'unreferenced'; - my $guesttext = $vmtype eq 'qemu' ? 'VM' : 'CT'; my $prefix = "$guesttext $vmid - volume '$volid' ($reference)"; @@ -799,19 +790,14 @@ sub check_storage_content { } if (!$scfg->{content}->{$vtype}) { - $found_referenced = 1 if $reference ne 'unreferenced'; - $found_unreferenced = 1 if $reference eq 'unreferenced'; + $found = 1; $pass = 0; log_warn("$prefix - storage does not have content type '$vtype' configured."); } }; - my $guests = {}; - my $cts = PVE::LXC::config_list(); for my $vmid (sort { $a <=> $b } keys %$cts) { - $guests->{$vmid} = 'lxc'; - my $conf = PVE::LXC::Config->load_config($vmid); my $volhash = {}; @@ -839,8 +825,6 @@ sub check_storage_content { my $vms = PVE::QemuServer::config_list(); for my $vmid (sort { $a <=> $b } keys %$vms) { - $guests->{$vmid} = 'qemu'; - my $conf = PVE::QemuConfig->load_config($vmid); my $volhash = {}; @@ -871,26 +855,11 @@ sub check_storage_content { } } - if ($found_referenced) { + if ($found) { log_warn("Proxmox VE 7.0 enforces stricter content type checks. The guests above " . "might not work until the storage configuration is fixed."); } - for my $volid (sort keys $potentially_affected->%*) { - next if $referenced_volids->{$volid}; # already checked - - my (undef, undef, $vmid) = PVE::Storage::parse_volname($storage_cfg, $volid); - my $vmtype = $guests->{$vmid}; - next if !$vmtype; - - $check_volid->($volid, $vmid, $vmtype, 'unreferenced'); - } - - if ($found_unreferenced) { - log_warn("When migrating, Proxmox VE 7.0 only scans storages with the appropriate " . - "content types for unreferenced guest volumes."); - } - if ($pass) { log_pass("no problems found"); }