1 package PVE
::CLI
::pve6to7
;
10 use PVE
::API2
::Certificates
;
11 use PVE
::API2
::Cluster
::Ceph
;
13 use PVE
::AccessControl
;
20 use PVE
::RPCEnvironment
;
22 use PVE
::Storage
::Plugin
;
23 use PVE
::Tools
qw(run_command split_list);
26 use PVE
::VZDump
::Common
;
35 use base
qw(PVE::CLIHandler);
37 my $nodename = PVE
::INotify
::nodename
();
39 sub setup_environment
{
40 PVE
::RPCEnvironment-
>setup_default_cli_env();
43 my $min_pve_major = 6;
44 my $min_pve_minor = 4;
45 my $min_pve_pkgrel = 1;
47 my $forced_legacy_cgroup = 0;
57 my ($level, $line) = @_;
59 $counters->{$level}++ if defined($level) && defined($counters->{$level});
61 print uc($level), ': ' if defined($level);
67 $log_line->('pass', @_);
72 $log_line->('info', @_);
75 $log_line->('skip', @_);
78 print color
('yellow');
79 $log_line->('warn', @_);
84 $log_line->('fail', @_);
88 my $print_header_first = 1;
91 print "\n" if !$print_header_first;
93 $print_header_first = 0;
96 my $get_systemd_unit_state = sub {
100 my $filter_output = sub {
105 run_command
(['systemctl', 'is-enabled', "$unit"], outfunc
=> $filter_output, noerr
=> 1);
106 return if !defined($state);
107 run_command
(['systemctl', 'is-active', "$unit"], outfunc
=> $filter_output, noerr
=> 1);
110 return $state // 'unknown';
112 my $log_systemd_unit_state = sub {
113 my ($unit, $no_fail_on_inactive) = @_;
115 my $log_method = \
&log_warn
;
117 my $state = $get_systemd_unit_state->($unit);
118 if ($state eq 'active') {
119 $log_method = \
&log_pass
;
120 } elsif ($state eq 'inactive') {
121 $log_method = $no_fail_on_inactive ? \
&log_warn
: \
&log_fail
;
122 } elsif ($state eq 'failed') {
123 $log_method = \
&log_fail
;
126 $log_method->("systemd unit '$unit' is in state '$state'");
133 $versions = eval { PVE
::API2
::APT-
>versions({ node
=> $nodename }) } if !defined($versions);
135 if (!defined($versions)) {
136 my $msg = "unable to retrieve package version information";
137 $msg .= "- $@" if $@;
142 my $pkgs = [ grep { $_->{Package
} eq $pkg } @$versions ];
143 if (!defined $pkgs || $pkgs == 0) {
144 log_fail
("unable to determine installed $pkg version.");
151 sub check_pve_packages
{
152 print_header
("CHECKING VERSION INFORMATION FOR PVE PACKAGES");
154 print "Checking for package updates..\n";
155 my $updates = eval { PVE
::API2
::APT-
>list_updates({ node
=> $nodename }); };
156 if (!defined($updates)) {
157 log_warn
("$@") if $@;
158 log_fail
("unable to retrieve list of package updates!");
159 } elsif (@$updates > 0) {
160 my $pkgs = join(', ', map { $_->{Package
} } @$updates);
161 log_warn
("updates for the following packages are available:\n $pkgs");
163 log_pass
("all packages uptodate");
166 print "\nChecking proxmox-ve package version..\n";
167 if (defined(my $proxmox_ve = $get_pkg->('proxmox-ve'))) {
168 my $min_pve_ver = "$min_pve_major.$min_pve_minor-$min_pve_pkgrel";
170 my ($maj, $min, $pkgrel) = $proxmox_ve->{OldVersion
} =~ m/^(\d+)\.(\d+)-(\d+)/;
174 if ($maj > $min_pve_major) {
175 log_pass
("already upgraded to Proxmox VE " . ($min_pve_major + 1));
177 } elsif ($maj >= $min_pve_major && $min >= $min_pve_minor && $pkgrel >= $min_pve_pkgrel) {
178 log_pass
("proxmox-ve package has version >= $min_pve_ver");
180 log_fail
("proxmox-ve package is too old, please upgrade to >= $min_pve_ver!");
183 my ($krunning, $kinstalled) = (qr/5\.11/, 'pve-kernel-5.11');
185 ($krunning, $kinstalled) = (qr/5\.(?:4|11)/, 'pve-kernel-4.15');
188 print "\nChecking running kernel version..\n";
189 my $kernel_ver = $proxmox_ve->{RunningKernel
};
190 if (!defined($kernel_ver)) {
191 log_fail
("unable to determine running kernel version.");
192 } elsif ($kernel_ver =~ /^$krunning/) {
193 log_pass
("expected running kernel '$kernel_ver'.");
194 } elsif ($get_pkg->($kinstalled)) {
195 log_warn
("expected kernel '$kinstalled' intalled but not yet rebooted!");
197 log_warn
("unexpected running and installed kernel '$kernel_ver'.");
200 log_fail
("proxmox-ve package not found!");
205 sub check_storage_health
{
206 print_header
("CHECKING CONFIGURED STORAGES");
207 my $cfg = PVE
::Storage
::config
();
211 my $info = PVE
::Storage
::storage_info
($cfg);
213 foreach my $storeid (sort keys %$info) {
214 my $d = $info->{$storeid};
216 if ($d->{type
} eq 'sheepdog') {
217 log_fail
("storage '$storeid' of type 'sheepdog' is enabled - experimental sheepdog support dropped in PVE 6")
218 } elsif ($d->{active
}) {
219 log_pass
("storage '$storeid' enabled and active.");
221 log_warn
("storage '$storeid' enabled but not active!");
224 log_skip
("storage '$storeid' disabled.");
229 sub check_cluster_corosync
{
230 print_header
("CHECKING CLUSTER HEALTH/SETTINGS");
232 if (!PVE
::Corosync
::check_conf_exists
(1)) {
233 log_skip
("standalone node.");
237 $log_systemd_unit_state->('pve-cluster.service');
238 $log_systemd_unit_state->('corosync.service');
240 if (PVE
::Cluster
::check_cfs_quorum
(1)) {
241 log_pass
("Cluster Filesystem is quorate.");
243 log_fail
("Cluster Filesystem readonly, lost quorum?!");
246 my $conf = PVE
::Cluster
::cfs_read_file
('corosync.conf');
247 my $conf_nodelist = PVE
::Corosync
::nodelist
($conf);
250 print "\nAnalzying quorum settings and state..\n";
251 if (!defined($conf_nodelist)) {
252 log_fail
("unable to retrieve nodelist from corosync.conf");
254 if (grep { $conf_nodelist->{$_}->{quorum_votes
} != 1 } keys %$conf_nodelist) {
255 log_warn
("non-default quorum_votes distribution detected!");
257 map { $node_votes += $conf_nodelist->{$_}->{quorum_votes
} // 0 } keys %$conf_nodelist;
260 my ($expected_votes, $total_votes);
261 my $filter_output = sub {
263 ($expected_votes) = $line =~ /^Expected votes:\s*(\d+)\s*$/
264 if !defined($expected_votes);
265 ($total_votes) = $line =~ /^Total votes:\s*(\d+)\s*$/
266 if !defined($total_votes);
269 run_command
(['corosync-quorumtool', '-s'], outfunc
=> $filter_output, noerr
=> 1);
272 if (!defined($expected_votes)) {
273 log_fail
("unable to get expected number of votes, setting to 0.");
276 if (!defined($total_votes)) {
277 log_fail
("unable to get expected number of votes, setting to 0.");
281 my $cfs_nodelist = PVE
::Cluster
::get_clinfo
()->{nodelist
};
282 my $offline_nodes = grep { $cfs_nodelist->{$_}->{online
} != 1 } keys %$cfs_nodelist;
283 if ($offline_nodes > 0) {
284 log_fail
("$offline_nodes nodes are offline!");
287 my $qdevice_votes = 0;
288 if (my $qdevice_setup = $conf->{main
}->{quorum
}->{device
}) {
289 $qdevice_votes = $qdevice_setup->{votes
} // 1;
292 log_info
("configured votes - nodes: $node_votes");
293 log_info
("configured votes - qdevice: $qdevice_votes");
294 log_info
("current expected votes: $expected_votes");
295 log_info
("current total votes: $total_votes");
297 log_warn
("expected votes set to non-standard value '$expected_votes'.")
298 if $expected_votes != $node_votes + $qdevice_votes;
299 log_warn
("total votes < expected votes: $total_votes/$expected_votes!")
300 if $total_votes < $expected_votes;
302 my $conf_nodelist_count = scalar(keys %$conf_nodelist);
303 my $cfs_nodelist_count = scalar(keys %$cfs_nodelist);
304 log_warn
("cluster consists of less than three quorum-providing nodes!")
305 if $conf_nodelist_count < 3 && $conf_nodelist_count + $qdevice_votes < 3;
307 log_fail
("corosync.conf ($conf_nodelist_count) and pmxcfs ($cfs_nodelist_count) don't agree about size of nodelist.")
308 if $conf_nodelist_count != $cfs_nodelist_count;
310 print "\nChecking nodelist entries..\n";
311 my $nodelist_pass = 1;
312 for my $cs_node (sort keys %$conf_nodelist) {
313 my $entry = $conf_nodelist->{$cs_node};
314 if (!defined($entry->{name
})) {
316 log_fail
("$cs_node: no name entry in corosync.conf.");
318 if (!defined($entry->{nodeid
})) {
320 log_fail
("$cs_node: no nodeid configured in corosync.conf.");
323 for my $link (0..7) {
324 $gotLinks++ if defined($entry->{"ring${link}_addr"});
326 if ($gotLinks <= 0) {
328 log_fail
("$cs_node: no ringX_addr (0 <= X <= 7) link defined in corosync.conf.");
331 my $verify_ring_ip = sub {
333 if (defined(my $ring = $entry->{$key})) {
334 my ($resolved_ip, undef) = PVE
::Corosync
::resolve_hostname_like_corosync
($ring, $conf);
335 if (defined($resolved_ip)) {
336 if ($resolved_ip ne $ring) {
338 log_warn
("$cs_node: $key '$ring' resolves to '$resolved_ip'.\n Consider replacing it with the currently resolved IP address.");
342 log_fail
("$cs_node: unable to resolve $key '$ring' to an IP address according to Corosync's resolve strategy - cluster will potentially fail with Corosync 3.x/kronosnet!");
346 for my $link (0..7) {
347 $verify_ring_ip->("ring${link}_addr");
350 log_pass
("nodelist settings OK") if $nodelist_pass;
352 print "\nChecking totem settings..\n";
353 my $totem = $conf->{main
}->{totem
};
356 my $transport = $totem->{transport
};
357 if (defined($transport)) {
358 if ($transport ne 'knet') {
360 log_fail
("Corosync transport explicitly set to '$transport' instead of implicit default!");
364 # TODO: are those values still up-to-date?
365 if ((!defined($totem->{secauth
}) || $totem->{secauth
} ne 'on') && (!defined($totem->{crypto_cipher
}) || $totem->{crypto_cipher
} eq 'none')) {
367 log_fail
("Corosync authentication/encryption is not explicitly enabled (secauth / crypto_cipher / crypto_hash)!");
368 } elsif (defined($totem->{crypto_cipher
}) && $totem->{crypto_cipher
} eq '3des') {
370 log_fail
("Corosync encryption cipher set to '3des', no longer supported in Corosync 3.x!"); # FIXME: can be removed?
373 log_pass
("totem settings OK") if $totem_pass;
375 log_info
("run 'pvecm status' to get detailed cluster status..");
377 if (defined(my $corosync = $get_pkg->('corosync'))) {
378 if ($corosync->{OldVersion
} =~ m/^2\./) {
379 log_fail
("\ncorosync 2.x installed, cluster-wide upgrade to 3.x needed!");
380 } elsif ($corosync->{OldVersion
} !~ m/^3\./) {
381 log_fail
("\nunexpected corosync version installed: $corosync->{OldVersion}!");
387 print_header
("CHECKING HYPER-CONVERGED CEPH STATUS");
389 if (PVE
::Ceph
::Tools
::check_ceph_inited
(1)) {
390 log_info
("hyper-converged ceph setup detected!");
392 log_skip
("no hyper-converged ceph setup detected!");
396 log_info
("getting Ceph status/health information..");
397 my $ceph_status = eval { PVE
::API2
::Ceph-
>status({ node
=> $nodename }); };
398 my $noout = eval { PVE
::API2
::Cluster
::Ceph-
>get_flag({ flag
=> "noout" }); };
400 log_fail
("failed to get 'noout' flag status - $@");
403 my $noout_wanted = 1;
405 if (!$ceph_status || !$ceph_status->{health
}) {
406 log_fail
("unable to determine Ceph status!");
408 my $ceph_health = $ceph_status->{health
}->{status
};
410 log_fail
("unable to determine Ceph health!");
411 } elsif ($ceph_health eq 'HEALTH_OK') {
412 log_pass
("Ceph health reported as 'HEALTH_OK'.");
413 } elsif ($ceph_health eq 'HEALTH_WARN' && $noout && (keys %{$ceph_status->{health
}->{checks
}} == 1)) {
414 log_pass
("Ceph health reported as 'HEALTH_WARN' with a single failing check and 'noout' flag set.");
416 log_warn
("Ceph health reported as '$ceph_health'.\n Use the PVE ".
417 "dashboard or 'ceph -s' to determine the specific issues and try to resolve them.");
421 # TODO: check OSD min-required version, if to low it breaks stuff!
423 log_info
("getting Ceph daemon versions..");
424 my $ceph_versions = eval { PVE
::Ceph
::Tools
::get_cluster_versions
(undef, 1); };
425 if (!$ceph_versions) {
426 log_fail
("unable to determine Ceph daemon versions!");
429 { 'key' => 'mon', 'name' => 'monitor' },
430 { 'key' => 'mgr', 'name' => 'manager' },
431 { 'key' => 'mds', 'name' => 'MDS' },
432 { 'key' => 'osd', 'name' => 'OSD' },
435 foreach my $service (@$services) {
436 my $name = $service->{name
};
437 if (my $service_versions = $ceph_versions->{$service->{key
}}) {
438 if (keys %$service_versions == 0) {
439 log_skip
("no running instances detected for daemon type $name.");
440 } elsif (keys %$service_versions == 1) {
441 log_pass
("single running version detected for daemon type $name.");
443 log_warn
("multiple running versions detected for daemon type $name!");
446 log_skip
("unable to determine versions of running Ceph $name instances.");
450 my $overall_versions = $ceph_versions->{overall
};
451 if (!$overall_versions) {
452 log_warn
("unable to determine overall Ceph daemon versions!");
453 } elsif (keys %$overall_versions == 1) {
454 log_pass
("single running overall version detected for all Ceph daemon types.");
455 $noout_wanted = 1; # off post-upgrade, on pre-upgrade
457 log_warn
("overall version mismatch detected, check 'ceph versions' output for details!");
463 log_pass
("'noout' flag set to prevent rebalancing during cluster-wide upgrades.");
465 log_warn
("'noout' flag set, Ceph cluster upgrade seems finished.");
467 } elsif ($noout_wanted) {
468 log_warn
("'noout' flag not set - recommended to prevent rebalancing during cluster-wide upgrades.");
471 log_info
("checking Ceph config..");
472 my $conf = PVE
::Cluster
::cfs_read_file
('ceph.conf');
474 my $global = $conf->{global
};
476 my $global_monhost = $global->{mon_host
} // $global->{"mon host"} // $global->{"mon-host"};
477 if (!defined($global_monhost)) {
478 log_warn
("No 'mon_host' entry found in ceph config.\n It's recommended to add mon_host with all monitor addresses (without ports) to the global section.");
481 my $ipv6 = $global->{ms_bind_ipv6
} // $global->{"ms bind ipv6"} // $global->{"ms-bind-ipv6"};
483 my $ipv4 = $global->{ms_bind_ipv4
} // $global->{"ms bind ipv4"} // $global->{"ms-bind-ipv4"};
484 if ($ipv6 eq 'true' && (!defined($ipv4) || $ipv4 ne 'false')) {
485 log_warn
("'ms_bind_ipv6' is enabled but 'ms_bind_ipv4' is not disabled.\n Make sure to disable 'ms_bind_ipv4' for ipv6 only clusters, or add an ipv4 network to public/cluster network.");
489 if (defined($global->{keyring
})) {
490 log_warn
("[global] config section contains 'keyring' option, which will prevent services from starting with Nautilus.\n Move 'keyring' option to [client] section instead.");
494 log_warn
("Empty ceph config found");
497 my $local_ceph_ver = PVE
::Ceph
::Tools
::get_local_version
(1);
498 if (defined($local_ceph_ver)) {
499 if ($local_ceph_ver <= 14) {
500 log_fail
("local Ceph version too low, at least Octopus required..");
503 log_fail
("unable to determine local Ceph version.");
507 sub check_backup_retention_settings
{
508 log_info
("Checking backup retention settings..");
512 my $node_has_retention;
514 my $maxfiles_msg = "parameter 'maxfiles' is deprecated with PVE 7.x and will be removed in a " .
515 "future version, use 'prune-backups' instead.";
518 my $confdesc = PVE
::VZDump
::Common
::get_confdesc
();
520 my $fn = "/etc/vzdump.conf";
521 my $raw = PVE
::Tools
::file_get_contents
($fn);
523 my $conf_schema = { type
=> 'object', properties
=> $confdesc, };
524 my $param = PVE
::JSONSchema
::parse_config
($conf_schema, $fn, $raw);
526 if (defined($param->{maxfiles
})) {
528 log_warn
("$fn - $maxfiles_msg");
531 $node_has_retention = defined($param->{maxfiles
}) || defined($param->{'prune-backups'});
535 log_warn
("unable to parse node's VZDump configuration - $err");
538 my $storage_cfg = PVE
::Storage
::config
();
540 for my $storeid (keys $storage_cfg->{ids
}->%*) {
541 my $scfg = $storage_cfg->{ids
}->{$storeid};
543 if (defined($scfg->{maxfiles
})) {
545 log_warn
("storage '$storeid' - $maxfiles_msg");
548 next if !$scfg->{content
}->{backup
};
549 next if defined($scfg->{maxfiles
}) || defined($scfg->{'prune-backups'});
550 next if $node_has_retention;
552 log_info
("storage '$storeid' - no backup retention settings defined - by default, PVE " .
553 "7.x will no longer keep only the last backup, but all backups");
557 my $vzdump_cron = PVE
::Cluster
::cfs_read_file
('vzdump.cron');
559 # only warn once, there might be many jobs...
560 if (scalar(grep { defined($_->{maxfiles
}) } $vzdump_cron->{jobs
}->@*)) {
562 log_warn
("/etc/pve/vzdump.cron - $maxfiles_msg");
567 log_warn
("unable to parse node's VZDump configuration - $err");
570 log_pass
("no problems found.") if $pass;
573 sub check_cifs_credential_location
{
574 log_info
("checking CIFS credential location..");
576 my $regex = qr/^(.*)\.cred$/;
580 PVE
::Tools
::dir_glob_foreach
('/etc/pve/priv/', $regex, sub {
583 my ($basename) = $filename =~ $regex;
585 log_warn
("CIFS credentials '/etc/pve/priv/$filename' will be moved to " .
586 "'/etc/pve/priv/storage/$basename.pw' during the update");
591 log_pass
("no CIFS credentials at outdated location found.") if !$found;
594 sub check_custom_pool_roles
{
595 log_info
("Checking custom roles for pool permissions..");
597 if (! -f
"/etc/pve/user.cfg") {
598 log_skip
("user.cfg does not exist");
602 my $raw = eval { PVE
::Tools
::file_get_contents
('/etc/pve/user.cfg'); };
604 log_fail
("Failed to read '/etc/pve/user.cfg' - $@");
609 while ($raw =~ /^\s*(.+?)\s*$/gm) {
613 foreach my $d (split (/:/, $line)) {
619 my $et = shift @data;
620 next if $et ne 'role';
622 my ($role, $privlist) = @data;
623 if (!PVE
::AccessControl
::verify_rolename
($role, 1)) {
624 warn "user config - ignore role '$role' - invalid characters in role name\n";
628 $roles->{$role} = {} if !$roles->{$role};
629 foreach my $priv (split_list
($privlist)) {
630 $roles->{$role}->{$priv} = 1;
634 foreach my $role (sort keys %{$roles}) {
635 if (PVE
::AccessControl
::role_is_special
($role)) {
639 if ($role eq "PVEPoolUser") {
640 # the user created a custom role named PVEPoolUser
641 log_fail
("Custom role '$role' has a restricted name - a built-in role 'PVEPoolUser' will be available with the upgrade");
643 log_pass
("Custom role '$role' has no restricted name");
646 my $perms = $roles->{$role};
647 if ($perms->{'Pool.Allocate'} && $perms->{'Pool.Audit'}) {
648 log_pass
("Custom role '$role' contains updated pool permissions");
649 } elsif ($perms->{'Pool.Allocate'}) {
650 log_warn
("Custom role '$role' contains permission 'Pool.Allocate' - to ensure same behavior add 'Pool.Audit' to this role");
652 log_pass
("Custom role '$role' contains no permissions that need to be updated");
657 my sub check_max_length
{
658 my ($raw, $max_length, $warning) = @_;
659 log_warn
($warning) if defined($raw) && length($raw) > $max_length;
662 sub check_node_and_guest_configurations
{
663 log_info
("Checking node and guest description/note legnth..");
665 my @affected_nodes = grep {
666 my $desc = PVE
::NodeConfig
::load_config
($_)->{desc
};
667 defined($desc) && length($desc) > 64 * 1024
668 } PVE
::Cluster
::get_nodelist
();
670 if (scalar(@affected_nodes) > 0) {
671 log_warn
("Node config description of the following nodes too long for new limit of 64 KiB:\n "
672 . join(', ', @affected_nodes));
674 log_pass
("All node config descriptions fit in the new limit of 64 KiB");
677 my $affected_guests_long_desc = [];
678 my $affected_cts_cgroup_keys = [];
680 my $cts = PVE
::LXC
::config_list
();
681 for my $vmid (sort { $a <=> $b } keys %$cts) {
682 my $conf = PVE
::LXC
::Config-
>load_config($vmid);
684 my $desc = $conf->{description
};
685 push @$affected_guests_long_desc, "CT $vmid" if defined($desc) && length($desc) > 8 * 1024;
687 my $lxc_raw_conf = $conf->{lxc
};
688 push @$affected_cts_cgroup_keys, "CT $vmid" if (grep (@$_[0] =~ /^lxc\.cgroup\./, @$lxc_raw_conf));
690 my $vms = PVE
::QemuServer
::config_list
();
691 for my $vmid (sort { $a <=> $b } keys %$vms) {
692 my $desc = PVE
::QemuConfig-
>load_config($vmid)->{description
};
693 push @$affected_guests_long_desc, "VM $vmid" if defined($desc) && length($desc) > 8 * 1024;
695 if (scalar($affected_guests_long_desc->@*) > 0) {
696 log_warn
("Guest config description of the following virtual-guests too long for new limit of 64 KiB:\n"
697 ." " . join(", ", $affected_guests_long_desc->@*));
699 log_pass
("All guest config descriptions fit in the new limit of 8 KiB");
702 log_info
("Checking container configs for deprecated lxc.cgroup entries");
704 if (scalar($affected_cts_cgroup_keys->@*) > 0) {
705 if ($forced_legacy_cgroup) {
706 log_pass
("Found legacy 'lxc.cgroup' keys, but system explicitly configured for legacy hybrid cgroup hierarchy.");
708 log_warn
("The following CTs have 'lxc.cgroup' keys configured, which will be ignored in the new default unified cgroupv2:\n"
709 ." " . join(", ", $affected_cts_cgroup_keys->@*) ."\n"
710 ." Often it can be enough to change to the new 'lxc.cgroup2' prefix after the upgrade to Proxmox VE 7.x");
713 log_pass
("No legacy 'lxc.cgroup' keys found.");
717 sub check_storage_content
{
718 log_info
("Checking storage content type configuration..");
723 my $storage_cfg = PVE
::Storage
::config
();
725 for my $storeid (sort keys $storage_cfg->{ids
}->%*) {
726 my $scfg = $storage_cfg->{ids
}->{$storeid};
728 next if $scfg->{shared
};
729 next if !PVE
::Storage
::storage_check_enabled
($storage_cfg, $storeid, undef, 1);
731 my $valid_content = PVE
::Storage
::Plugin
::valid_content_types
($scfg->{type
});
733 if (scalar(keys $scfg->{content
}->%*) == 0 && !$valid_content->{none
}) {
735 log_fail
("storage '$storeid' does not support configured content type 'none'");
736 delete $scfg->{content
}->{none
}; # scan for guest images below
739 next if $scfg->{content
}->{images
};
740 next if $scfg->{content
}->{rootdir
};
742 # Skip 'iscsi(direct)' (and foreign plugins with potentially similiar behavior) with 'none',
743 # because that means "use LUNs directly" and vdisk_list() in PVE 6.x still lists those.
744 # It's enough to *not* skip 'dir', because it is the only other storage that supports 'none'
745 # and 'images' or 'rootdir', hence being potentially misconfigured.
746 next if $scfg->{type
} ne 'dir' && $scfg->{content
}->{none
};
748 eval { PVE
::Storage
::activate_storage
($storage_cfg, $storeid) };
750 log_warn
("activating '$storeid' failed - $err");
754 my $res = eval { PVE
::Storage
::vdisk_list
($storage_cfg, $storeid); };
756 log_warn
("listing images on '$storeid' failed - $err");
759 my @volids = map { $_->{volid
} } $res->{$storeid}->@*;
761 my $number = scalar(@volids);
763 log_info
("storage '$storeid' - neither content type 'images' nor 'rootdir' configured"
764 .", but found $number guest volume(s)");
768 my $check_volid = sub {
769 my ($volid, $vmid, $vmtype, $reference) = @_;
771 my $guesttext = $vmtype eq 'qemu' ?
'VM' : 'CT';
772 my $prefix = "$guesttext $vmid - volume '$volid' ($reference)";
774 my ($storeid) = PVE
::Storage
::parse_volume_id
($volid, 1);
775 return if !defined($storeid);
777 my $scfg = $storage_cfg->{ids
}->{$storeid};
780 log_warn
("$prefix - storage does not exist!");
784 # cannot use parse_volname for containers, as it can return 'images'
785 # but containers cannot have ISO images attached, so assume 'rootdir'
786 my $vtype = 'rootdir';
787 if ($vmtype eq 'qemu') {
788 ($vtype) = eval { PVE
::Storage
::parse_volname
($storage_cfg, $volid); };
792 if (!$scfg->{content
}->{$vtype}) {
795 log_warn
("$prefix - storage does not have content type '$vtype' configured.");
799 my $cts = PVE
::LXC
::config_list
();
800 for my $vmid (sort { $a <=> $b } keys %$cts) {
801 my $conf = PVE
::LXC
::Config-
>load_config($vmid);
806 my ($ms, $mountpoint, $reference) = @_;
808 my $volid = $mountpoint->{volume
};
809 return if !$volid || $mountpoint->{type
} ne 'volume';
811 return if $volhash->{$volid}; # volume might be referenced multiple times
813 $volhash->{$volid} = 1;
815 $check_volid->($volid, $vmid, 'lxc', $reference);
818 my $opts = { include_unused
=> 1 };
819 PVE
::LXC
::Config-
>foreach_volume_full($conf, $opts, $check, 'in config');
820 for my $snapname (keys $conf->{snapshots
}->%*) {
821 my $snap = $conf->{snapshots
}->{$snapname};
822 PVE
::LXC
::Config-
>foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'");
826 my $vms = PVE
::QemuServer
::config_list
();
827 for my $vmid (sort { $a <=> $b } keys %$vms) {
828 my $conf = PVE
::QemuConfig-
>load_config($vmid);
833 my ($key, $drive, $reference) = @_;
835 my $volid = $drive->{file
};
836 return if $volid =~ m
|^/|;
838 return if $volhash->{$volid}; # volume might be referenced multiple times
840 $volhash->{$volid} = 1;
842 $check_volid->($volid, $vmid, 'qemu', $reference);
846 extra_keys
=> ['vmstate'],
849 # startup from a suspended state works even without 'images' content type on the
850 # state storage, so do not check 'vmstate' for $conf
851 PVE
::QemuConfig-
>foreach_volume_full($conf, { include_unused
=> 1 }, $check, 'in config');
852 for my $snapname (keys $conf->{snapshots
}->%*) {
853 my $snap = $conf->{snapshots
}->{$snapname};
854 PVE
::QemuConfig-
>foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'");
859 log_warn
("Proxmox VE 7.0 enforces stricter content type checks. The guests above " .
860 "might not work until the storage configuration is fixed.");
864 log_pass
("no problems found");
868 sub check_containers_cgroup_compat
{
869 if ($forced_legacy_cgroup) {
870 log_skip
("System explicitly configured for legacy hybrid cgroup hierarchy.");
874 my $supports_cgroupv2 = sub {
875 my ($conf, $rootdir, $ctid) = @_;
877 my $get_systemd_version = sub {
880 my $sd_lib_dir = -d
"/lib/systemd" ?
"/lib/systemd" : "/usr/lib/systemd";
881 my $libsd = PVE
::Tools
::dir_glob_regex
($sd_lib_dir, "libsystemd-shared-.+\.so");
882 if (defined($libsd) && $libsd =~ /libsystemd-shared-(\d+)\.so/) {
889 my $unified_cgroupv2_support = sub {
892 # https://www.freedesktop.org/software/systemd/man/systemd.html
893 # systemd is installed as symlink to /sbin/init
894 my $systemd = CORE
::readlink('/sbin/init');
896 # assume non-systemd init will run with unified cgroupv2
897 if (!defined($systemd) || $systemd !~ m
@/systemd$@) {
901 # systemd version 232 (e.g. debian stretch) supports the unified hierarchy
902 my $sdver = $get_systemd_version->();
903 if (!defined($sdver) || $sdver < 232) {
910 my $ostype = $conf->{ostype
};
911 if (!defined($ostype)) {
912 log_warn
("Found CT ($ctid) without 'ostype' set!");
913 } elsif ($ostype eq 'devuan' || $ostype eq 'alpine') {
914 return 1; # no systemd, no cgroup problems
917 my $lxc_setup = PVE
::LXC
::Setup-
>new($conf, $rootdir);
918 return $lxc_setup->protected_call($unified_cgroupv2_support);
921 my $log_problem = sub {
923 log_warn
("Found at least one CT ($ctid) which does not support running in a unified cgroup v2" .
924 " layout.\n Either upgrade the Container distro or set systemd.unified_cgroup_hierarchy=0 " .
925 "in the Proxmox VE hosts' kernel cmdline! Skipping further CT compat checks."
929 my $cts = eval { PVE
::API2
::LXC-
>vmlist({ node
=> $nodename }) };
931 log_warn
("Failed to retrieve information about this node's CTs - $@");
935 if (!defined($cts) || !scalar(@$cts)) {
936 log_skip
("No containers on node detected.");
940 my @running_cts = sort { $a <=> $b } grep { $_->{status
} eq 'running' } @$cts;
941 my @offline_cts = sort { $a <=> $b } grep { $_->{status
} ne 'running' } @$cts;
943 for my $ct (@running_cts) {
944 my $ctid = $ct->{vmid
};
945 my $pid = eval { PVE
::LXC
::find_lxc_pid
($ctid) };
947 log_warn
("Failed to get PID for running CT $ctid - $err");
950 my $rootdir = "/proc/$pid/root";
951 my $conf = PVE
::LXC
::Config-
>load_config($ctid);
953 my $ret = eval { $supports_cgroupv2->($conf, $rootdir, $ctid) };
955 log_warn
("Failed to get cgroup support status for CT $ctid - $err");
959 $log_problem->($ctid);
964 my $storage_cfg = PVE
::Storage
::config
();
965 for my $ct (@offline_cts) {
966 my $ctid = $ct->{vmid
};
967 my ($conf, $rootdir, $ret);
969 $conf = PVE
::LXC
::Config-
>load_config($ctid);
970 $rootdir = PVE
::LXC
::mount_all
($ctid, $storage_cfg, $conf);
971 $ret = $supports_cgroupv2->($conf, $rootdir, $ctid);
974 log_warn
("Failed to load config and mount CT $ctid - $err");
975 eval { PVE
::LXC
::umount_all
($ctid, $storage_cfg, $conf) };
979 $log_problem->($ctid);
980 eval { PVE
::LXC
::umount_all
($ctid, $storage_cfg, $conf) };
984 eval { PVE
::LXC
::umount_all
($ctid, $storage_cfg, $conf) };
988 sub check_security_repo
{
989 log_info
("Checking if the suite for the Debian security repository is correct..");
993 my $dir = '/etc/apt/sources.list.d';
996 my $check_file = sub {
999 $file = "${dir}/${file}" if $in_dir;
1001 my $raw = eval { PVE
::Tools
::file_get_contents
($file) };
1002 return if !defined($raw);
1003 my @lines = split(/\n/, $raw);
1006 for my $line (@lines) {
1009 next if length($line) == 0; # split would result in undef then...
1011 ($line) = split(/#/, $line);
1013 next if $line !~ m/^deb/; # is case sensitive
1018 # https://deb.debian.org/debian-security
1019 # http://security.debian.org/debian-security
1020 # http://security.debian.org/
1021 if ($line =~ m
|https?
://deb\
.debian\
.org
/debian-security/?\s
+(\S
*)|i
) {
1023 } elsif ($line =~ m
|https?
://security\
.debian\
.org
(?
:.*?
)\s
+(\S
*)|i
) {
1031 my $where = "in ${file}:${number}";
1033 if ($suite eq 'buster/updates') {
1034 log_info
("Make sure to change the suite of the Debian security repository " .
1035 "from 'buster/updates' to 'bullseye-security' - $where");
1036 } elsif ($suite eq 'bullseye-security') {
1037 log_pass
("already using 'bullseye-security'");
1039 log_fail
("The new suite of the Debian security repository should be " .
1040 "'bullseye-security' - $where");
1045 $check_file->("/etc/apt/sources.list");
1049 PVE
::Tools
::dir_glob_foreach
($dir, '^.*\.list$', $check_file);
1052 # only warn, it might be defined in a .sources file or in a way not catched above
1053 log_warn
("No Debian security repository detected in /etc/apt/sources.list and " .
1054 "/etc/apt/sources.list.d/*.list");
1059 print_header
("MISCELLANEOUS CHECKS");
1060 my $ssh_config = eval { PVE
::Tools
::file_get_contents
('/root/.ssh/config') };
1061 if (defined($ssh_config)) {
1062 log_fail
("Unsupported SSH Cipher configured for root in /root/.ssh/config: $1")
1063 if $ssh_config =~ /^Ciphers .*(blowfish|arcfour|3des).*$/m;
1065 log_skip
("No SSH config file found.");
1068 log_info
("Checking common daemon services..");
1069 $log_systemd_unit_state->('pveproxy.service');
1070 $log_systemd_unit_state->('pvedaemon.service');
1071 $log_systemd_unit_state->('pvestatd.service');
1073 my $root_free = PVE
::Tools
::df
('/', 10);
1074 log_warn
("Less than 4 GiB free space on root file system.")
1075 if defined($root_free) && $root_free->{avail
} < 4*1024*1024*1024;
1077 log_info
("Checking for running guests..");
1078 my $running_guests = 0;
1080 my $vms = eval { PVE
::API2
::Qemu-
>vmlist({ node
=> $nodename }) };
1081 log_warn
("Failed to retrieve information about this node's VMs - $@") if $@;
1082 $running_guests += grep { $_->{status
} eq 'running' } @$vms if defined($vms);
1084 my $cts = eval { PVE
::API2
::LXC-
>vmlist({ node
=> $nodename }) };
1085 log_warn
("Failed to retrieve information about this node's CTs - $@") if $@;
1086 $running_guests += grep { $_->{status
} eq 'running' } @$cts if defined($cts);
1088 if ($running_guests > 0) {
1089 log_warn
("$running_guests running guest(s) detected - consider migrating or stopping them.")
1091 log_pass
("no running guest detected.")
1094 log_info
("Checking if the local node's hostname '$nodename' is resolvable..");
1095 my $local_ip = eval { PVE
::Network
::get_ip_from_hostname
($nodename) };
1097 log_warn
("Failed to resolve hostname '$nodename' to IP - $@");
1099 log_info
("Checking if resolved IP is configured on local node..");
1100 my $cidr = Net
::IP
::ip_is_ipv6
($local_ip) ?
"$local_ip/128" : "$local_ip/32";
1101 my $configured_ips = PVE
::Network
::get_local_ip_from_cidr
($cidr);
1102 my $ip_count = scalar(@$configured_ips);
1104 if ($ip_count <= 0) {
1105 log_fail
("Resolved node IP '$local_ip' not configured or active for '$nodename'");
1106 } elsif ($ip_count > 1) {
1107 log_warn
("Resolved node IP '$local_ip' active on multiple ($ip_count) interfaces!");
1109 log_pass
("Resolved node IP '$local_ip' configured and active on single interface.");
1113 my $certs = PVE
::API2
::Certificates-
>info({ node
=> $nodename });
1115 'rsaEncryption' => {
1119 'id-ecPublicKey' => {
1125 my $log_cert_heading_called;
1126 my $log_cert_heading_once = sub {
1127 return if $log_cert_heading_called;
1128 log_info
("Check node certificate's RSA key size");
1129 $log_cert_heading_called = 1;
1132 my $certs_check_failed = 0;
1133 foreach my $cert (@$certs) {
1134 my ($type, $size, $fn) = $cert->@{qw(public-key-type public-key-bits filename)};
1136 if (!defined($type) || !defined($size)) {
1137 $log_cert_heading_once->();
1138 log_warn
("'$fn': cannot check certificate, failed to get it's type or size!");
1141 my $check = $certs_check->{$type};
1142 if (!defined($check)) {
1143 $log_cert_heading_once->();
1144 log_warn
("'$fn': certificate's public key type '$type' unknown, check Debian Busters release notes");
1148 if ($size < $check->{minsize
}) {
1149 $log_cert_heading_once->();
1150 log_fail
("'$fn', certificate's $check->{name} public key size is less than 2048 bit");
1151 $certs_check_failed = 1;
1155 check_backup_retention_settings
();
1156 check_cifs_credential_location
();
1157 check_custom_pool_roles
();
1158 check_node_and_guest_configurations
();
1159 check_storage_content
();
1160 check_security_repo
();
1163 __PACKAGE__-
>register_method ({
1164 name
=> 'checklist',
1165 path
=> 'checklist',
1167 description
=> 'Check (pre-/post-)upgrade conditions.',
1169 additionalProperties
=> 0,
1172 description
=> 'perform additional, expensive checks.',
1179 returns
=> { type
=> 'null' },
1183 my $kernel_cli = PVE
::Tools
::file_get_contents
('/proc/cmdline');
1184 if ($kernel_cli =~ /systemd.unified_cgroup_hierarchy=0/){
1185 $forced_legacy_cgroup = 1;
1188 check_pve_packages
();
1189 check_cluster_corosync
();
1191 check_storage_health
();
1194 if ($param->{full
}) {
1195 check_containers_cgroup_compat
();
1197 log_skip
("NOTE: Expensive checks, like CT cgroupv2 compat, not performed without '--full' parameter");
1200 print_header
("SUMMARY");
1203 $total += $_ for values %$counters;
1205 print "TOTAL: $total\n";
1206 print colored
("PASSED: $counters->{pass}\n", 'green');
1207 print "SKIPPED: $counters->{skip}\n";
1208 print colored
("WARNINGS: $counters->{warn}\n", 'yellow');
1209 print colored
("FAILURES: $counters->{fail}\n", 'red');
1211 if ($counters->{warn} > 0 || $counters->{fail
} > 0) {
1212 my $color = $counters->{fail
} > 0 ?
'red' : 'yellow';
1213 print colored
("\nATTENTION: Please check the output for detailed information!\n", $color);
1214 print colored
("Try to solve the problems one at a time and then run this checklist tool again.\n", $color) if $counters->{fail
} > 0;
1220 our $cmddef = [ __PACKAGE__
, 'checklist', [], {}];