]> git.proxmox.com Git - pve-manager.git/blame - PVE/CLI/pve6to7.pm
pve6to7: add check for Debian security repository
[pve-manager.git] / PVE / CLI / pve6to7.pm
CommitLineData
4177a14d
TL
1package PVE::CLI::pve6to7;
2
3use strict;
4use warnings;
5
6use PVE::API2::APT;
7use PVE::API2::Ceph;
8use PVE::API2::LXC;
9use PVE::API2::Qemu;
10use PVE::API2::Certificates;
5a77d2ca 11use PVE::API2::Cluster::Ceph;
4177a14d 12
31e4ad5d 13use PVE::AccessControl;
4177a14d
TL
14use PVE::Ceph::Tools;
15use PVE::Cluster;
16use PVE::Corosync;
17use PVE::INotify;
18use PVE::JSONSchema;
1be86a36 19use PVE::NodeConfig;
4177a14d
TL
20use PVE::RPCEnvironment;
21use PVE::Storage;
8e120220 22use PVE::Storage::Plugin;
31e4ad5d 23use PVE::Tools qw(run_command split_list);
1be86a36 24use PVE::QemuConfig;
4177a14d 25use PVE::QemuServer;
44090816 26use PVE::VZDump::Common;
372b7372
SI
27use PVE::LXC;
28use PVE::LXC::Config;
29use PVE::LXC::Setup;
4177a14d
TL
30
31use Term::ANSIColor;
32
33use PVE::CLIHandler;
34
35use base qw(PVE::CLIHandler);
36
37my $nodename = PVE::INotify::nodename();
38
39sub setup_environment {
40 PVE::RPCEnvironment->setup_default_cli_env();
41}
42
43my $min_pve_major = 6;
44my $min_pve_minor = 4;
45my $min_pve_pkgrel = 1;
46
edb91999
TL
47my $forced_legacy_cgroup = 0;
48
4177a14d
TL
49my $counters = {
50 pass => 0,
51 skip => 0,
52 warn => 0,
53 fail => 0,
54};
55
56my $log_line = sub {
57 my ($level, $line) = @_;
58
59 $counters->{$level}++ if defined($level) && defined($counters->{$level});
60
61 print uc($level), ': ' if defined($level);
62 print "$line\n";
63};
64
65sub log_pass {
66 print color('green');
67 $log_line->('pass', @_);
68 print color('reset');
69}
70
71sub log_info {
72 $log_line->('info', @_);
73}
74sub log_skip {
75 $log_line->('skip', @_);
76}
77sub log_warn {
78 print color('yellow');
79 $log_line->('warn', @_);
80 print color('reset');
81}
82sub log_fail {
83 print color('red');
84 $log_line->('fail', @_);
85 print color('reset');
86}
87
88my $print_header_first = 1;
89sub print_header {
90 my ($h) = @_;
91 print "\n" if !$print_header_first;
92 print "= $h =\n\n";
93 $print_header_first = 0;
94}
95
96my $get_systemd_unit_state = sub {
97 my ($unit) = @_;
98
99 my $state;
100 my $filter_output = sub {
101 $state = shift;
102 chomp $state;
103 };
104 eval {
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);
108 };
109
110 return $state // 'unknown';
111};
112my $log_systemd_unit_state = sub {
113 my ($unit, $no_fail_on_inactive) = @_;
114
115 my $log_method = \&log_warn;
116
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;
124 }
125
126 $log_method->("systemd unit '$unit' is in state '$state'");
127};
128
129my $versions;
130my $get_pkg = sub {
131 my ($pkg) = @_;
132
133 $versions = eval { PVE::API2::APT->versions({ node => $nodename }) } if !defined($versions);
134
135 if (!defined($versions)) {
136 my $msg = "unable to retrieve package version information";
137 $msg .= "- $@" if $@;
138 log_fail("$msg");
139 return undef;
140 }
141
142 my $pkgs = [ grep { $_->{Package} eq $pkg } @$versions ];
143 if (!defined $pkgs || $pkgs == 0) {
144 log_fail("unable to determine installed $pkg version.");
145 return undef;
146 } else {
147 return $pkgs->[0];
148 }
149};
150
151sub check_pve_packages {
152 print_header("CHECKING VERSION INFORMATION FOR PVE PACKAGES");
153
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");
162 } else {
163 log_pass("all packages uptodate");
164 }
165
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";
169
170 my ($maj, $min, $pkgrel) = $proxmox_ve->{OldVersion} =~ m/^(\d+)\.(\d+)-(\d+)/;
171
172 my $upgraded = 0;
173
174 if ($maj > $min_pve_major) {
175 log_pass("already upgraded to Proxmox VE " . ($min_pve_major + 1));
176 $upgraded = 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");
179 } else {
180 log_fail("proxmox-ve package is too old, please upgrade to >= $min_pve_ver!");
181 }
182
183 my ($krunning, $kinstalled) = (qr/5\.11/, 'pve-kernel-5.11');
184 if (!$upgraded) {
185 ($krunning, $kinstalled) = (qr/5\.(?:4|11)/, 'pve-kernel-4.15');
186 }
187
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!");
196 } else {
197 log_warn("unexpected running and installed kernel '$kernel_ver'.");
198 }
199 } else {
200 log_fail("proxmox-ve package not found!");
201 }
202}
203
204
205sub check_storage_health {
206 print_header("CHECKING CONFIGURED STORAGES");
207 my $cfg = PVE::Storage::config();
208
209 my $ctime = time();
210
211 my $info = PVE::Storage::storage_info($cfg);
212
e37e8fc7 213 foreach my $storeid (sort keys %$info) {
4177a14d
TL
214 my $d = $info->{$storeid};
215 if ($d->{enabled}) {
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.");
220 } else {
221 log_warn("storage '$storeid' enabled but not active!");
222 }
223 } else {
224 log_skip("storage '$storeid' disabled.");
225 }
226 }
227}
228
229sub check_cluster_corosync {
230 print_header("CHECKING CLUSTER HEALTH/SETTINGS");
231
232 if (!PVE::Corosync::check_conf_exists(1)) {
233 log_skip("standalone node.");
234 return;
235 }
236
237 $log_systemd_unit_state->('pve-cluster.service');
238 $log_systemd_unit_state->('corosync.service');
239
240 if (PVE::Cluster::check_cfs_quorum(1)) {
241 log_pass("Cluster Filesystem is quorate.");
242 } else {
243 log_fail("Cluster Filesystem readonly, lost quorum?!");
244 }
245
246 my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
247 my $conf_nodelist = PVE::Corosync::nodelist($conf);
248 my $node_votes = 0;
249
250 print "\nAnalzying quorum settings and state..\n";
251 if (!defined($conf_nodelist)) {
252 log_fail("unable to retrieve nodelist from corosync.conf");
253 } else {
254 if (grep { $conf_nodelist->{$_}->{quorum_votes} != 1 } keys %$conf_nodelist) {
255 log_warn("non-default quorum_votes distribution detected!");
256 }
257 map { $node_votes += $conf_nodelist->{$_}->{quorum_votes} // 0 } keys %$conf_nodelist;
258 }
259
260 my ($expected_votes, $total_votes);
261 my $filter_output = sub {
262 my $line = shift;
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);
267 };
268 eval {
269 run_command(['corosync-quorumtool', '-s'], outfunc => $filter_output, noerr => 1);
270 };
271
272 if (!defined($expected_votes)) {
273 log_fail("unable to get expected number of votes, setting to 0.");
274 $expected_votes = 0;
275 }
276 if (!defined($total_votes)) {
277 log_fail("unable to get expected number of votes, setting to 0.");
278 $total_votes = 0;
279 }
280
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!");
285 }
286
287 my $qdevice_votes = 0;
288 if (my $qdevice_setup = $conf->{main}->{quorum}->{device}) {
289 $qdevice_votes = $qdevice_setup->{votes} // 1;
290 }
291
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");
296
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;
301
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;
306
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;
309
310 print "\nChecking nodelist entries..\n";
e0c54858 311 my $nodelist_pass = 1;
4177a14d
TL
312 for my $cs_node (sort keys %$conf_nodelist) {
313 my $entry = $conf_nodelist->{$cs_node};
e0c54858
FG
314 if (!defined($entry->{name})) {
315 $nodelist_pass = 0;
316 log_fail("$cs_node: no name entry in corosync.conf.");
317 }
318 if (!defined($entry->{nodeid})) {
319 $nodelist_pass = 0;
320 log_fail("$cs_node: no nodeid configured in corosync.conf.");
321 }
4177a14d
TL
322 my $gotLinks = 0;
323 for my $link (0..7) {
324 $gotLinks++ if defined($entry->{"ring${link}_addr"});
325 }
e0c54858
FG
326 if ($gotLinks <= 0) {
327 $nodelist_pass = 0;
328 log_fail("$cs_node: no ringX_addr (0 <= X <= 7) link defined in corosync.conf.");
329 }
4177a14d
TL
330
331 my $verify_ring_ip = sub {
332 my $key = shift;
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) {
e0c54858 337 $nodelist_pass = 0;
4177a14d 338 log_warn("$cs_node: $key '$ring' resolves to '$resolved_ip'.\n Consider replacing it with the currently resolved IP address.");
4177a14d
TL
339 }
340 } else {
e0c54858 341 $nodelist_pass = 0;
4177a14d
TL
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!");
343 }
344 }
345 };
346 for my $link (0..7) {
347 $verify_ring_ip->("ring${link}_addr");
348 }
349 }
e0c54858 350 log_pass("nodelist settings OK") if $nodelist_pass;
4177a14d
TL
351
352 print "\nChecking totem settings..\n";
353 my $totem = $conf->{main}->{totem};
e0c54858
FG
354 my $totem_pass = 1;
355
4177a14d
TL
356 my $transport = $totem->{transport};
357 if (defined($transport)) {
358 if ($transport ne 'knet') {
e0c54858 359 $totem_pass = 0;
4177a14d 360 log_fail("Corosync transport explicitly set to '$transport' instead of implicit default!");
4177a14d 361 }
4177a14d
TL
362 }
363
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')) {
e0c54858 366 $totem_pass = 0;
4177a14d 367 log_fail("Corosync authentication/encryption is not explicitly enabled (secauth / crypto_cipher / crypto_hash)!");
e0c54858
FG
368 } elsif (defined($totem->{crypto_cipher}) && $totem->{crypto_cipher} eq '3des') {
369 $totem_pass = 0;
370 log_fail("Corosync encryption cipher set to '3des', no longer supported in Corosync 3.x!"); # FIXME: can be removed?
4177a14d
TL
371 }
372
e0c54858 373 log_pass("totem settings OK") if $totem_pass;
4177a14d
TL
374 print "\n";
375 log_info("run 'pvecm status' to get detailed cluster status..");
376
4177a14d
TL
377 if (defined(my $corosync = $get_pkg->('corosync'))) {
378 if ($corosync->{OldVersion} =~ m/^2\./) {
e0c54858
FG
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}!");
4177a14d
TL
382 }
383 }
384}
385
386sub check_ceph {
387 print_header("CHECKING HYPER-CONVERGED CEPH STATUS");
388
389 if (PVE::Ceph::Tools::check_ceph_inited(1)) {
390 log_info("hyper-converged ceph setup detected!");
391 } else {
392 log_skip("no hyper-converged ceph setup detected!");
393 return;
394 }
395
396 log_info("getting Ceph status/health information..");
397 my $ceph_status = eval { PVE::API2::Ceph->status({ node => $nodename }); };
5a77d2ca
FG
398 my $noout = eval { PVE::API2::Cluster::Ceph->get_flag({ flag => "noout" }); };
399 if ($@) {
400 log_fail("failed to get 'noout' flag status - $@");
401 }
402
4177a14d 403 my $noout_wanted = 1;
4177a14d
TL
404
405 if (!$ceph_status || !$ceph_status->{health}) {
406 log_fail("unable to determine Ceph status!");
407 } else {
408 my $ceph_health = $ceph_status->{health}->{status};
409 if (!$ceph_health) {
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.");
415 } else {
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.");
418 }
419 }
420
4177a14d
TL
421 # TODO: check OSD min-required version, if to low it breaks stuff!
422
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!");
427 } else {
428 my $services = [
429 { 'key' => 'mon', 'name' => 'monitor' },
430 { 'key' => 'mgr', 'name' => 'manager' },
431 { 'key' => 'mds', 'name' => 'MDS' },
432 { 'key' => 'osd', 'name' => 'OSD' },
433 ];
434
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.");
442 } else {
443 log_warn("multiple running versions detected for daemon type $name!");
444 }
445 } else {
446 log_skip("unable to determine versions of running Ceph $name instances.");
447 }
448 }
449
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.");
3b776617 455 $noout_wanted = 1; # off post-upgrade, on pre-upgrade
4177a14d
TL
456 } else {
457 log_warn("overall version mismatch detected, check 'ceph versions' output for details!");
458 }
459 }
460
461 if ($noout) {
462 if ($noout_wanted) {
463 log_pass("'noout' flag set to prevent rebalancing during cluster-wide upgrades.");
464 } else {
465 log_warn("'noout' flag set, Ceph cluster upgrade seems finished.");
466 }
467 } elsif ($noout_wanted) {
aaf792a5 468 log_warn("'noout' flag not set - recommended to prevent rebalancing during cluster-wide upgrades.");
4177a14d
TL
469 }
470
471 log_info("checking Ceph config..");
472 my $conf = PVE::Cluster::cfs_read_file('ceph.conf');
473 if (%$conf) {
474 my $global = $conf->{global};
475
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.");
4177a14d
TL
479 }
480
481 my $ipv6 = $global->{ms_bind_ipv6} // $global->{"ms bind ipv6"} // $global->{"ms-bind-ipv6"};
482 if ($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.");
4177a14d 486 }
4177a14d
TL
487 }
488
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.");
4177a14d
TL
491 }
492
493 } else {
494 log_warn("Empty ceph config found");
495 }
496
497 my $local_ceph_ver = PVE::Ceph::Tools::get_local_version(1);
498 if (defined($local_ceph_ver)) {
742fbff5
FG
499 if ($local_ceph_ver <= 14) {
500 log_fail("local Ceph version too low, at least Octopus required..");
4177a14d
TL
501 }
502 } else {
503 log_fail("unable to determine local Ceph version.");
504 }
505}
506
44090816
FE
507sub check_backup_retention_settings {
508 log_info("Checking backup retention settings..");
509
510 my $pass = 1;
511
512 my $node_has_retention;
513
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.";
516
517 eval {
518 my $confdesc = PVE::VZDump::Common::get_confdesc();
519
520 my $fn = "/etc/vzdump.conf";
521 my $raw = PVE::Tools::file_get_contents($fn);
522
523 my $conf_schema = { type => 'object', properties => $confdesc, };
524 my $param = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw);
525
526 if (defined($param->{maxfiles})) {
527 $pass = 0;
528 log_warn("$fn - $maxfiles_msg");
529 }
530
531 $node_has_retention = defined($param->{maxfiles}) || defined($param->{'prune-backups'});
532 };
533 if (my $err = $@) {
534 $pass = 0;
535 log_warn("unable to parse node's VZDump configuration - $err");
536 }
537
538 my $storage_cfg = PVE::Storage::config();
539
540 for my $storeid (keys $storage_cfg->{ids}->%*) {
541 my $scfg = $storage_cfg->{ids}->{$storeid};
542
543 if (defined($scfg->{maxfiles})) {
544 $pass = 0;
545 log_warn("storage '$storeid' - $maxfiles_msg");
546 }
547
548 next if !$scfg->{content}->{backup};
549 next if defined($scfg->{maxfiles}) || defined($scfg->{'prune-backups'});
550 next if $node_has_retention;
551
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");
554 }
555
35933450
FG
556 eval {
557 my $vzdump_cron = PVE::Cluster::cfs_read_file('vzdump.cron');
44090816 558
35933450
FG
559 # only warn once, there might be many jobs...
560 if (scalar(grep { defined($_->{maxfiles}) } $vzdump_cron->{jobs}->@*)) {
561 $pass = 0;
562 log_warn("/etc/pve/vzdump.cron - $maxfiles_msg");
563 }
564 };
565 if (my $err = $@) {
44090816 566 $pass = 0;
35933450 567 log_warn("unable to parse node's VZDump configuration - $err");
44090816
FE
568 }
569
570 log_pass("no problems found.") if $pass;
571}
572
0390b62e
FE
573sub check_cifs_credential_location {
574 log_info("checking CIFS credential location..");
575
576 my $regex = qr/^(.*)\.cred$/;
577
578 my $found;
579
580 PVE::Tools::dir_glob_foreach('/etc/pve/priv/', $regex, sub {
581 my ($filename) = @_;
582
583 my ($basename) = $filename =~ $regex;
584
585 log_warn("CIFS credentials '/etc/pve/priv/$filename' will be moved to " .
586 "'/etc/pve/priv/storage/$basename.pw' during the update");
587
588 $found = 1;
589 });
590
591 log_pass("no CIFS credentials at outdated location found.") if !$found;
592}
593
31e4ad5d
LS
594sub check_custom_pool_roles {
595 log_info("Checking custom roles for pool permissions..");
596
86aa9d44
DC
597 if (! -f "/etc/pve/user.cfg") {
598 log_skip("user.cfg does not exist");
599 return;
600 }
601
d817b524
FG
602 my $raw = eval { PVE::Tools::file_get_contents('/etc/pve/user.cfg'); };
603 if ($@) {
604 log_fail("Failed to read '/etc/pve/user.cfg' - $@");
605 return;
606 }
31e4ad5d
LS
607
608 my $roles = {};
b5f89880
FG
609 while ($raw =~ /^\s*(.+?)\s*$/gm) {
610 my $line = $1;
611 my @data;
612
613 foreach my $d (split (/:/, $line)) {
614 $d =~ s/^\s+//;
615 $d =~ s/\s+$//;
616 push @data, $d
617 }
618
619 my $et = shift @data;
620 next if $et ne 'role';
31e4ad5d 621
b5f89880 622 my ($role, $privlist) = @data;
31e4ad5d
LS
623 if (!PVE::AccessControl::verify_rolename($role, 1)) {
624 warn "user config - ignore role '$role' - invalid characters in role name\n";
625 next;
626 }
627
628 $roles->{$role} = {} if !$roles->{$role};
629 foreach my $priv (split_list($privlist)) {
630 $roles->{$role}->{$priv} = 1;
631 }
632 }
633
634 foreach my $role (sort keys %{$roles}) {
635 if (PVE::AccessControl::role_is_special($role)) {
636 next;
637 }
638
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");
642 } else {
643 log_pass("Custom role '$role' has no restricted name");
644 }
645
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");
651 } else {
652 log_pass("Custom role '$role' contains no permissions that need to be updated");
653 }
654 }
655}
656
56142f8c
TL
657my sub check_max_length {
658 my ($raw, $max_length, $warning) = @_;
659 log_warn($warning) if defined($raw) && length($raw) > $max_length;
660}
661
1a38ffbc 662sub check_node_and_guest_configurations {
1be86a36
LS
663 log_info("Checking node and guest description/note legnth..");
664
56142f8c
TL
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();
1be86a36 669
56142f8c
TL
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));
673 } else {
674 log_pass("All node config descriptions fit in the new limit of 64 KiB");
1be86a36
LS
675 }
676
1a38ffbc
TL
677 my $affected_guests_long_desc = [];
678 my $affected_cts_cgroup_keys = [];
56142f8c
TL
679
680 my $cts = PVE::LXC::config_list();
681 for my $vmid (sort { $a <=> $b } keys %$cts) {
1a38ffbc
TL
682 my $conf = PVE::LXC::Config->load_config($vmid);
683
684 my $desc = $conf->{description};
685 push @$affected_guests_long_desc, "CT $vmid" if defined($desc) && length($desc) > 8 * 1024;
686
687 my $lxc_raw_conf = $conf->{lxc};
688 push @$affected_cts_cgroup_keys, "CT $vmid" if (grep (@$_[0] =~ /^lxc\.cgroup\./, @$lxc_raw_conf));
56142f8c 689 }
1be86a36 690 my $vms = PVE::QemuServer::config_list();
56142f8c
TL
691 for my $vmid (sort { $a <=> $b } keys %$vms) {
692 my $desc = PVE::QemuConfig->load_config($vmid)->{description};
1a38ffbc 693 push @$affected_guests_long_desc, "VM $vmid" if defined($desc) && length($desc) > 8 * 1024;
56142f8c 694 }
1a38ffbc 695 if (scalar($affected_guests_long_desc->@*) > 0) {
953c9d22 696 log_warn("Guest config description of the following virtual-guests too long for new limit of 64 KiB:\n"
1a38ffbc 697 ." " . join(", ", $affected_guests_long_desc->@*));
56142f8c
TL
698 } else {
699 log_pass("All guest config descriptions fit in the new limit of 8 KiB");
1be86a36 700 }
1a38ffbc
TL
701
702 log_info("Checking container configs for deprecated lxc.cgroup entries");
703
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.");
707 } else {
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");
711 }
712 } else {
713 log_pass("No legacy 'lxc.cgroup' keys found.");
714 }
1be86a36
LS
715}
716
09828717 717sub check_storage_content {
8e120220 718 log_info("Checking storage content type configuration..");
09828717 719
4968c944
FE
720 my $found_referenced;
721 my $found_unreferenced;
04421bd7 722 my $pass = 1;
09828717
FE
723
724 my $storage_cfg = PVE::Storage::config();
725
4968c944
FE
726 my $potentially_affected = {};
727 my $referenced_volids = {};
728
e37e8fc7 729 for my $storeid (sort keys $storage_cfg->{ids}->%*) {
09828717
FE
730 my $scfg = $storage_cfg->{ids}->{$storeid};
731
732 next if !PVE::Storage::storage_check_enabled($storage_cfg, $storeid, undef, 1);
733
8e120220
FE
734 my $valid_content = PVE::Storage::Plugin::valid_content_types($scfg->{type});
735
736 if (scalar(keys $scfg->{content}->%*) == 0 && !$valid_content->{none}) {
04421bd7 737 $pass = 0;
8e120220
FE
738 log_fail("storage '$storeid' does not support configured content type 'none'");
739 delete $scfg->{content}->{none}; # scan for guest images below
740 }
741
4968c944 742 next if $scfg->{content}->{images} && $scfg->{content}->{rootdir};
09828717
FE
743
744 # Skip 'iscsi(direct)' (and foreign plugins with potentially similiar behavior) with 'none',
745 # because that means "use LUNs directly" and vdisk_list() in PVE 6.x still lists those.
746 # It's enough to *not* skip 'dir', because it is the only other storage that supports 'none'
747 # and 'images' or 'rootdir', hence being potentially misconfigured.
748 next if $scfg->{type} ne 'dir' && $scfg->{content}->{none};
749
4968c944
FE
750 eval { PVE::Storage::activate_storage($storage_cfg, $storeid) };
751 if (my $err = $@) {
752 log_warn("activating '$storeid' failed - $err");
753 next;
754 }
755
756 my $res = eval { PVE::Storage::vdisk_list($storage_cfg, $storeid); };
757 if (my $err = $@) {
758 log_warn("listing images on '$storeid' failed - $err");
759 next;
760 }
761 my @volids = map { $_->{volid} } $res->{$storeid}->@*;
762
763 for my $volid (@volids) {
764 $potentially_affected->{$volid} = 1;
765 }
766
767 my $number = scalar(@volids);
768 if ($number > 0 && !$scfg->{content}->{images} && !$scfg->{content}->{rootdir}) {
769 log_info("storage '$storeid' - neither content type 'images' nor 'rootdir' configured"
770 .", but found $number guest volume(s)");
771 }
772 }
773
774 my $check_volid = sub {
775 my ($volid, $vmid, $vmtype, $reference) = @_;
776
777 $referenced_volids->{$volid} = 1 if $reference ne 'unreferenced';
778
779 my $guesttext = $vmtype eq 'qemu' ? 'VM' : 'CT';
780 my $prefix = "$guesttext $vmid - volume '$volid' ($reference)";
09828717 781
4968c944
FE
782 my ($storeid) = PVE::Storage::parse_volume_id($volid, 1);
783 return if !defined($storeid);
09828717 784
4968c944
FE
785 my $scfg = $storage_cfg->{ids}->{$storeid};
786 if (!$scfg) {
04421bd7 787 $pass = 0;
4968c944
FE
788 log_warn("$prefix - storage does not exist!");
789 return;
790 }
791
792 # cannot use parse_volname for containers, as it can return 'images'
793 # but containers cannot have ISO images attached, so assume 'rootdir'
794 my $vtype = 'rootdir';
795 if ($vmtype eq 'qemu') {
796 ($vtype) = eval { PVE::Storage::parse_volname($storage_cfg, $volid); };
797 return if $@;
09828717 798 }
4968c944
FE
799
800 if (!$scfg->{content}->{$vtype}) {
801 $found_referenced = 1 if $reference ne 'unreferenced';
802 $found_unreferenced = 1 if $reference eq 'unreferenced';
803 $pass = 0;
804 log_warn("$prefix - storage does not have content type '$vtype' configured.");
805 }
806 };
807
808 my $guests = {};
809
810 my $cts = PVE::LXC::config_list();
811 for my $vmid (sort { $a <=> $b } keys %$cts) {
812 $guests->{$vmid} = 'lxc';
813
814 my $conf = PVE::LXC::Config->load_config($vmid);
815
816 my $volhash = {};
817
818 my $check = sub {
819 my ($ms, $mountpoint, $reference) = @_;
820
821 my $volid = $mountpoint->{volume};
822 return if !$volid || $mountpoint->{type} ne 'volume';
823
824 return if $volhash->{$volid}; # volume might be referenced multiple times
825
826 $volhash->{$volid} = 1;
827
828 $check_volid->($volid, $vmid, 'lxc', $reference);
829 };
830
831 my $opts = { include_unused => 1 };
832 PVE::LXC::Config->foreach_volume_full($conf, $opts, $check, 'in config');
833 for my $snapname (keys $conf->{snapshots}->%*) {
834 my $snap = $conf->{snapshots}->{$snapname};
835 PVE::LXC::Config->foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'");
836 }
837 }
838
839 my $vms = PVE::QemuServer::config_list();
840 for my $vmid (sort { $a <=> $b } keys %$vms) {
841 $guests->{$vmid} = 'qemu';
842
843 my $conf = PVE::QemuConfig->load_config($vmid);
844
845 my $volhash = {};
846
847 my $check = sub {
848 my ($key, $drive, $reference) = @_;
849
850 my $volid = $drive->{file};
851 return if $volid =~ m|^/|;
852
853 return if $volhash->{$volid}; # volume might be referenced multiple times
854
855 $volhash->{$volid} = 1;
856
857 $check_volid->($volid, $vmid, 'qemu', $reference);
858 };
859
860 my $opts = {
861 extra_keys => ['vmstate'],
862 include_unused => 1,
863 };
864 # startup from a suspended state works even without 'images' content type on the
865 # state storage, so do not check 'vmstate' for $conf
866 PVE::QemuConfig->foreach_volume_full($conf, { include_unused => 1 }, $check, 'in config');
867 for my $snapname (keys $conf->{snapshots}->%*) {
868 my $snap = $conf->{snapshots}->{$snapname};
869 PVE::QemuConfig->foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'");
870 }
871 }
872
873 if ($found_referenced) {
874 log_warn("Proxmox VE 7.0 enforces stricter content type checks. The guests above " .
875 "might not work until the storage configuration is fixed.");
876 }
877
878 for my $volid (sort keys $potentially_affected->%*) {
879 next if $referenced_volids->{$volid}; # already checked
880
881 my (undef, undef, $vmid) = PVE::Storage::parse_volname($storage_cfg, $volid);
882 my $vmtype = $guests->{$vmid};
883 next if !$vmtype;
884
885 $check_volid->($volid, $vmid, $vmtype, 'unreferenced');
09828717
FE
886 }
887
4968c944
FE
888 if ($found_unreferenced) {
889 log_warn("When migrating, Proxmox VE 7.0 only scans storages with the appropriate " .
890 "content types for unreferenced guest volumes.");
04421bd7
FE
891 }
892
893 if ($pass) {
8e120220 894 log_pass("no problems found");
09828717
FE
895 }
896}
897
372b7372 898sub check_containers_cgroup_compat {
edb91999 899 if ($forced_legacy_cgroup) {
372b7372
SI
900 log_skip("System explicitly configured for legacy hybrid cgroup hierarchy.");
901 return;
902 }
903
904 my $supports_cgroupv2 = sub {
af5ddc95 905 my ($conf, $rootdir, $ctid) = @_;
372b7372
SI
906
907 my $get_systemd_version = sub {
908 my ($self) = @_;
909
910 my $sd_lib_dir = -d "/lib/systemd" ? "/lib/systemd" : "/usr/lib/systemd";
911 my $libsd = PVE::Tools::dir_glob_regex($sd_lib_dir, "libsystemd-shared-.+\.so");
912 if (defined($libsd) && $libsd =~ /libsystemd-shared-(\d+)\.so/) {
913 return $1;
914 }
915
916 return undef;
917 };
918
919 my $unified_cgroupv2_support = sub {
920 my ($self) = @_;
921
922 # https://www.freedesktop.org/software/systemd/man/systemd.html
923 # systemd is installed as symlink to /sbin/init
924 my $systemd = CORE::readlink('/sbin/init');
925
926 # assume non-systemd init will run with unified cgroupv2
927 if (!defined($systemd) || $systemd !~ m@/systemd$@) {
928 return 1;
929 }
930
931 # systemd version 232 (e.g. debian stretch) supports the unified hierarchy
932 my $sdver = $get_systemd_version->();
933 if (!defined($sdver) || $sdver < 232) {
934 return 0;
935 }
936
937 return 1;
938 };
939
940 my $ostype = $conf->{ostype};
af5ddc95
TL
941 if (!defined($ostype)) {
942 log_warn("Found CT ($ctid) without 'ostype' set!");
943 } elsif ($ostype eq 'devuan' || $ostype eq 'alpine') {
944 return 1; # no systemd, no cgroup problems
372b7372
SI
945 }
946
947 my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir);
948 return $lxc_setup->protected_call($unified_cgroupv2_support);
949 };
950
951 my $log_problem = sub {
952 my ($ctid) = @_;
4839422a
TL
953 log_warn("Found at least one CT ($ctid) which does not support running in a unified cgroup v2" .
954 " layout.\n Either upgrade the Container distro or set systemd.unified_cgroup_hierarchy=0 " .
955 "in the Proxmox VE hosts' kernel cmdline! Skipping further CT compat checks."
372b7372
SI
956 );
957 };
958
959 my $cts = eval { PVE::API2::LXC->vmlist({ node => $nodename }) };
960 if ($@) {
961 log_warn("Failed to retrieve information about this node's CTs - $@");
962 return;
963 }
964
965 if (!defined($cts) || !scalar(@$cts)) {
966 log_skip("No containers on node detected.");
967 return;
968 }
969
e37e8fc7
TL
970 my @running_cts = sort { $a <=> $b } grep { $_->{status} eq 'running' } @$cts;
971 my @offline_cts = sort { $a <=> $b } grep { $_->{status} ne 'running' } @$cts;
372b7372
SI
972
973 for my $ct (@running_cts) {
974 my $ctid = $ct->{vmid};
975 my $pid = eval { PVE::LXC::find_lxc_pid($ctid) };
976 if (my $err = $@) {
977 log_warn("Failed to get PID for running CT $ctid - $err");
978 next;
979 }
980 my $rootdir = "/proc/$pid/root";
981 my $conf = PVE::LXC::Config->load_config($ctid);
982
af5ddc95 983 my $ret = eval { $supports_cgroupv2->($conf, $rootdir, $ctid) };
372b7372
SI
984 if (my $err = $@) {
985 log_warn("Failed to get cgroup support status for CT $ctid - $err");
986 next;
987 }
988 if (!$ret) {
989 $log_problem->($ctid);
990 return;
991 }
992 }
993
994 my $storage_cfg = PVE::Storage::config();
995 for my $ct (@offline_cts) {
996 my $ctid = $ct->{vmid};
997 my ($conf, $rootdir, $ret);
998 eval {
999 $conf = PVE::LXC::Config->load_config($ctid);
1000 $rootdir = PVE::LXC::mount_all($ctid, $storage_cfg, $conf);
af5ddc95 1001 $ret = $supports_cgroupv2->($conf, $rootdir, $ctid);
372b7372
SI
1002 };
1003 if (my $err = $@) {
1004 log_warn("Failed to load config and mount CT $ctid - $err");
1005 eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) };
1006 next;
1007 }
1008 if (!$ret) {
1009 $log_problem->($ctid);
1010 eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) };
1011 last;
1012 }
1013
1014 eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) };
1015 }
1016};
1017
559587bd
FE
1018sub check_security_repo {
1019 log_info("Checking if the suite for the Debian security repository is correct..");
1020
1021 my $found = 0;
1022
1023 my $dir = '/etc/apt/sources.list.d';
1024 my $in_dir = 0;
1025
1026 my $check_file = sub {
1027 my ($file) = @_;
1028
1029 $file = "${dir}/${file}" if $in_dir;
1030
1031 my $raw = eval { PVE::Tools::file_get_contents($file) };
1032 return if !defined($raw);
1033 my @lines = split(/\n/, $raw);
1034
1035 my $number = 0;
1036 for my $line (@lines) {
1037 $number++;
1038
1039 next if length($line) == 0; # split would result in undef then...
1040
1041 ($line) = split(/#/, $line);
1042
1043 next if $line !~ m/^deb/; # is case sensitive
1044
1045 my $suite;
1046
1047 # catch any of
1048 # https://deb.debian.org/debian-security
1049 # http://security.debian.org/debian-security
1050 # http://security.debian.org/
1051 if ($line =~ m|https?://deb\.debian\.org/debian-security/?\s+(\S*)|i) {
1052 $suite = $1;
1053 } elsif ($line =~ m|https?://security\.debian\.org(?:.*?)\s+(\S*)|i) {
1054 $suite = $1;
1055 } else {
1056 next;
1057 }
1058
1059 $found = 1;
1060
1061 my $where = "in ${file}:${number}";
1062
1063 if ($suite eq 'buster/updates') {
1064 log_info("Make sure to change the suite of the Debian security repository " .
1065 "from 'buster/updates' to 'bullseye-security' - $where");
1066 } elsif ($suite eq 'bullseye-security') {
1067 log_pass("already using 'bullseye-security'");
1068 } else {
1069 log_fail("The new suite of the Debian security repository should be " .
1070 "'bullseye-security' - $where");
1071 }
1072 }
1073 };
1074
1075 $check_file->("/etc/apt/sources.list");
1076
1077 $in_dir = 1;
1078
1079 PVE::Tools::dir_glob_foreach($dir, '^.*\.list$', $check_file);
1080
1081 if (!$found) {
1082 # only warn, it might be defined in a .sources file or in a way not catched above
1083 log_warn("No Debian security repository detected in /etc/apt/sources.list and " .
1084 "/etc/apt/sources.list.d/*.list");
1085 }
1086}
1087
4177a14d
TL
1088sub check_misc {
1089 print_header("MISCELLANEOUS CHECKS");
1090 my $ssh_config = eval { PVE::Tools::file_get_contents('/root/.ssh/config') };
1091 if (defined($ssh_config)) {
1092 log_fail("Unsupported SSH Cipher configured for root in /root/.ssh/config: $1")
1093 if $ssh_config =~ /^Ciphers .*(blowfish|arcfour|3des).*$/m;
1094 } else {
1095 log_skip("No SSH config file found.");
1096 }
1097
1098 log_info("Checking common daemon services..");
1099 $log_systemd_unit_state->('pveproxy.service');
1100 $log_systemd_unit_state->('pvedaemon.service');
1101 $log_systemd_unit_state->('pvestatd.service');
1102
1103 my $root_free = PVE::Tools::df('/', 10);
21aa5446
TL
1104 log_warn("Less than 4 GiB free space on root file system.")
1105 if defined($root_free) && $root_free->{avail} < 4*1024*1024*1024;
4177a14d
TL
1106
1107 log_info("Checking for running guests..");
1108 my $running_guests = 0;
1109
1110 my $vms = eval { PVE::API2::Qemu->vmlist({ node => $nodename }) };
1111 log_warn("Failed to retrieve information about this node's VMs - $@") if $@;
1112 $running_guests += grep { $_->{status} eq 'running' } @$vms if defined($vms);
1113
1114 my $cts = eval { PVE::API2::LXC->vmlist({ node => $nodename }) };
1115 log_warn("Failed to retrieve information about this node's CTs - $@") if $@;
1116 $running_guests += grep { $_->{status} eq 'running' } @$cts if defined($cts);
1117
1118 if ($running_guests > 0) {
1119 log_warn("$running_guests running guest(s) detected - consider migrating or stopping them.")
1120 } else {
1121 log_pass("no running guest detected.")
1122 }
1123
1124 log_info("Checking if the local node's hostname '$nodename' is resolvable..");
1125 my $local_ip = eval { PVE::Network::get_ip_from_hostname($nodename) };
1126 if ($@) {
1127 log_warn("Failed to resolve hostname '$nodename' to IP - $@");
1128 } else {
1129 log_info("Checking if resolved IP is configured on local node..");
1130 my $cidr = Net::IP::ip_is_ipv6($local_ip) ? "$local_ip/128" : "$local_ip/32";
1131 my $configured_ips = PVE::Network::get_local_ip_from_cidr($cidr);
1132 my $ip_count = scalar(@$configured_ips);
1133
1134 if ($ip_count <= 0) {
1135 log_fail("Resolved node IP '$local_ip' not configured or active for '$nodename'");
1136 } elsif ($ip_count > 1) {
1137 log_warn("Resolved node IP '$local_ip' active on multiple ($ip_count) interfaces!");
1138 } else {
1139 log_pass("Resolved node IP '$local_ip' configured and active on single interface.");
1140 }
1141 }
1142
4177a14d
TL
1143 my $certs = PVE::API2::Certificates->info({ node => $nodename });
1144 my $certs_check = {
1145 'rsaEncryption' => {
1146 minsize => 2048,
1147 name => 'RSA',
1148 },
1149 'id-ecPublicKey' => {
1150 minsize => 224,
1151 name => 'ECC',
1152 },
1153 };
1154
24cbb9d8
TL
1155 my $log_cert_heading_called;
1156 my $log_cert_heading_once = sub {
1157 return if $log_cert_heading_called;
1158 log_info("Check node certificate's RSA key size");
1159 $log_cert_heading_called = 1;
1160 };
1161
4177a14d
TL
1162 my $certs_check_failed = 0;
1163 foreach my $cert (@$certs) {
1164 my ($type, $size, $fn) = $cert->@{qw(public-key-type public-key-bits filename)};
1165
1166 if (!defined($type) || !defined($size)) {
24cbb9d8 1167 $log_cert_heading_once->();
4177a14d
TL
1168 log_warn("'$fn': cannot check certificate, failed to get it's type or size!");
1169 }
1170
1171 my $check = $certs_check->{$type};
1172 if (!defined($check)) {
24cbb9d8 1173 $log_cert_heading_once->();
4177a14d
TL
1174 log_warn("'$fn': certificate's public key type '$type' unknown, check Debian Busters release notes");
1175 next;
1176 }
1177
1178 if ($size < $check->{minsize}) {
24cbb9d8 1179 $log_cert_heading_once->();
4177a14d
TL
1180 log_fail("'$fn', certificate's $check->{name} public key size is less than 2048 bit");
1181 $certs_check_failed = 1;
4177a14d
TL
1182 }
1183 }
44090816
FE
1184
1185 check_backup_retention_settings();
0390b62e 1186 check_cifs_credential_location();
31e4ad5d 1187 check_custom_pool_roles();
1a38ffbc 1188 check_node_and_guest_configurations();
09828717 1189 check_storage_content();
559587bd 1190 check_security_repo();
4177a14d
TL
1191}
1192
1193__PACKAGE__->register_method ({
1194 name => 'checklist',
1195 path => 'checklist',
1196 method => 'GET',
1197 description => 'Check (pre-/post-)upgrade conditions.',
1198 parameters => {
1199 additionalProperties => 0,
1200 properties => {
6b5d4878
SI
1201 full => {
1202 description => 'perform additional, expensive checks.',
1203 type => 'boolean',
1204 optional => 1,
1205 default => 0,
1206 },
4177a14d
TL
1207 },
1208 },
1209 returns => { type => 'null' },
1210 code => sub {
1211 my ($param) = @_;
1212
edb91999
TL
1213 my $kernel_cli = PVE::Tools::file_get_contents('/proc/cmdline');
1214 if ($kernel_cli =~ /systemd.unified_cgroup_hierarchy=0/){
1215 $forced_legacy_cgroup = 1;
1216 }
1217
4177a14d
TL
1218 check_pve_packages();
1219 check_cluster_corosync();
1220 check_ceph();
1221 check_storage_health();
1222 check_misc();
1223
6b5d4878
SI
1224 if ($param->{full}) {
1225 check_containers_cgroup_compat();
1226 } else {
f32b1f03 1227 log_skip("NOTE: Expensive checks, like CT cgroupv2 compat, not performed without '--full' parameter");
6b5d4878
SI
1228 }
1229
4177a14d
TL
1230 print_header("SUMMARY");
1231
1232 my $total = 0;
1233 $total += $_ for values %$counters;
1234
1235 print "TOTAL: $total\n";
1236 print colored("PASSED: $counters->{pass}\n", 'green');
1237 print "SKIPPED: $counters->{skip}\n";
1238 print colored("WARNINGS: $counters->{warn}\n", 'yellow');
1239 print colored("FAILURES: $counters->{fail}\n", 'red');
1240
1241 if ($counters->{warn} > 0 || $counters->{fail} > 0) {
1242 my $color = $counters->{fail} > 0 ? 'red' : 'yellow';
1243 print colored("\nATTENTION: Please check the output for detailed information!\n", $color);
1244 print colored("Try to solve the problems one at a time and then run this checklist tool again.\n", $color) if $counters->{fail} > 0;
1245 }
1246
1247 return undef;
1248 }});
1249
1250our $cmddef = [ __PACKAGE__, 'checklist', [], {}];
1251
4177a14d 12521;