]>
Commit | Line | Data |
---|---|---|
a98193c2 TL |
1 | package PVE::CLI::pve7to8; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
eed1e93e TL |
6 | use Cwd (); |
7 | ||
a98193c2 TL |
8 | use PVE::API2::APT; |
9 | use PVE::API2::Ceph; | |
10 | use PVE::API2::LXC; | |
11 | use PVE::API2::Qemu; | |
12 | use PVE::API2::Certificates; | |
13 | use PVE::API2::Cluster::Ceph; | |
14 | ||
15 | use PVE::AccessControl; | |
16 | use PVE::Ceph::Tools; | |
17 | use PVE::Cluster; | |
18 | use PVE::Corosync; | |
19 | use PVE::INotify; | |
20 | use PVE::JSONSchema; | |
21 | use PVE::NodeConfig; | |
22 | use PVE::RPCEnvironment; | |
23 | use PVE::Storage; | |
24 | use PVE::Storage::Plugin; | |
eed1e93e | 25 | use PVE::Tools qw(run_command split_list file_get_contents); |
a98193c2 TL |
26 | use PVE::QemuConfig; |
27 | use PVE::QemuServer; | |
28 | use PVE::VZDump::Common; | |
29 | use PVE::LXC; | |
30 | use PVE::LXC::Config; | |
31 | use PVE::LXC::Setup; | |
32 | ||
33 | use Term::ANSIColor; | |
34 | ||
35 | use PVE::CLIHandler; | |
36 | ||
37 | use base qw(PVE::CLIHandler); | |
38 | ||
39 | my $nodename = PVE::INotify::nodename(); | |
40 | ||
eed1e93e TL |
41 | my $upgraded = 0; # set in check_pve_packages |
42 | ||
a98193c2 TL |
43 | sub setup_environment { |
44 | PVE::RPCEnvironment->setup_default_cli_env(); | |
45 | } | |
46 | ||
114e5f2c TL |
47 | my $new_suite = 'bookworm'; |
48 | my $old_suite = 'bullseye'; | |
49 | my $older_suites = { | |
50 | buster => 1, | |
51 | stretch => 1, | |
52 | jessie => 1, | |
53 | }; | |
54 | ||
a98193c2 TL |
55 | my ($min_pve_major, $min_pve_minor, $min_pve_pkgrel) = (7, 4, 1); |
56 | ||
57 | my $ceph_release2code = { | |
58 | '12' => 'Luminous', | |
59 | '13' => 'Mimic', | |
60 | '14' => 'Nautilus', | |
61 | '15' => 'Octopus', | |
62 | '16' => 'Pacific', | |
63 | '17' => 'Quincy', | |
64 | '18' => 'Reef', | |
65 | }; | |
66 | my $ceph_supported_release = 17; # the version we support for upgrading (i.e., available on both) | |
67 | my $ceph_supported_code_name = $ceph_release2code->{"$ceph_supported_release"} | |
68 | or die "inconsistent source code, could not map expected ceph version to code name!"; | |
69 | ||
70 | my $forced_legacy_cgroup = 0; | |
71 | ||
72 | my $counters = { | |
73 | pass => 0, | |
74 | skip => 0, | |
114e5f2c | 75 | notice => 0, |
a98193c2 TL |
76 | warn => 0, |
77 | fail => 0, | |
78 | }; | |
79 | ||
114e5f2c TL |
80 | my $level2color = { |
81 | pass => 'green', | |
82 | notice => 'bold', | |
83 | warn => 'yellow', | |
84 | fail => 'bold red', | |
85 | }; | |
86 | ||
a98193c2 TL |
87 | my $log_line = sub { |
88 | my ($level, $line) = @_; | |
89 | ||
90 | $counters->{$level}++ if defined($level) && defined($counters->{$level}); | |
91 | ||
114e5f2c TL |
92 | my $color = $level2color->{$level} // ''; |
93 | print color($color) if $color && $color ne ''; | |
94 | ||
a98193c2 TL |
95 | print uc($level), ': ' if defined($level); |
96 | print "$line\n"; | |
a98193c2 | 97 | |
a98193c2 | 98 | print color('reset'); |
114e5f2c | 99 | }; |
a98193c2 | 100 | |
114e5f2c TL |
101 | sub log_pass { $log_line->('pass', @_); } |
102 | sub log_info { $log_line->('info', @_); } | |
103 | sub log_skip { $log_line->('skip', @_); } | |
104 | sub log_notice { $log_line->('notice', @_); } | |
105 | sub log_warn { $log_line->('warn', @_); } | |
106 | sub log_fail { $log_line->('fail', @_); } | |
a98193c2 TL |
107 | |
108 | my $print_header_first = 1; | |
109 | sub print_header { | |
110 | my ($h) = @_; | |
111 | print "\n" if !$print_header_first; | |
112 | print "= $h =\n\n"; | |
113 | $print_header_first = 0; | |
114 | } | |
115 | ||
116 | my $get_systemd_unit_state = sub { | |
ffa79167 | 117 | my ($unit, $suppress_stderr) = @_; |
a98193c2 TL |
118 | |
119 | my $state; | |
120 | my $filter_output = sub { | |
121 | $state = shift; | |
122 | chomp $state; | |
123 | }; | |
124 | ||
125 | my %extra = (outfunc => $filter_output, noerr => 1); | |
ffa79167 | 126 | $extra{errfunc} = sub { } if $suppress_stderr; |
a98193c2 TL |
127 | |
128 | eval { | |
129 | run_command(['systemctl', 'is-enabled', "$unit"], %extra); | |
130 | return if !defined($state); | |
131 | run_command(['systemctl', 'is-active', "$unit"], %extra); | |
132 | }; | |
133 | ||
134 | return $state // 'unknown'; | |
135 | }; | |
136 | my $log_systemd_unit_state = sub { | |
137 | my ($unit, $no_fail_on_inactive) = @_; | |
138 | ||
139 | my $log_method = \&log_warn; | |
140 | ||
141 | my $state = $get_systemd_unit_state->($unit); | |
142 | if ($state eq 'active') { | |
143 | $log_method = \&log_pass; | |
144 | } elsif ($state eq 'inactive') { | |
145 | $log_method = $no_fail_on_inactive ? \&log_warn : \&log_fail; | |
146 | } elsif ($state eq 'failed') { | |
147 | $log_method = \&log_fail; | |
148 | } | |
149 | ||
150 | $log_method->("systemd unit '$unit' is in state '$state'"); | |
151 | }; | |
152 | ||
153 | my $versions; | |
154 | my $get_pkg = sub { | |
155 | my ($pkg) = @_; | |
156 | ||
157 | $versions = eval { PVE::API2::APT->versions({ node => $nodename }) } if !defined($versions); | |
158 | ||
159 | if (!defined($versions)) { | |
160 | my $msg = "unable to retrieve package version information"; | |
161 | $msg .= "- $@" if $@; | |
162 | log_fail("$msg"); | |
163 | return undef; | |
164 | } | |
165 | ||
166 | my $pkgs = [ grep { $_->{Package} eq $pkg } @$versions ]; | |
167 | if (!defined $pkgs || $pkgs == 0) { | |
168 | log_fail("unable to determine installed $pkg version."); | |
169 | return undef; | |
170 | } else { | |
171 | return $pkgs->[0]; | |
172 | } | |
173 | }; | |
174 | ||
175 | sub check_pve_packages { | |
176 | print_header("CHECKING VERSION INFORMATION FOR PVE PACKAGES"); | |
177 | ||
178 | print "Checking for package updates..\n"; | |
179 | my $updates = eval { PVE::API2::APT->list_updates({ node => $nodename }); }; | |
180 | if (!defined($updates)) { | |
181 | log_warn("$@") if $@; | |
182 | log_fail("unable to retrieve list of package updates!"); | |
183 | } elsif (@$updates > 0) { | |
184 | my $pkgs = join(', ', map { $_->{Package} } @$updates); | |
185 | log_warn("updates for the following packages are available:\n $pkgs"); | |
186 | } else { | |
eed1e93e | 187 | log_pass("all packages up-to-date"); |
a98193c2 TL |
188 | } |
189 | ||
190 | print "\nChecking proxmox-ve package version..\n"; | |
191 | if (defined(my $proxmox_ve = $get_pkg->('proxmox-ve'))) { | |
45d1707c | 192 | # TODO: update to native version for pve8to9 |
a98193c2 TL |
193 | my $min_pve_ver = "$min_pve_major.$min_pve_minor-$min_pve_pkgrel"; |
194 | ||
45d1707c | 195 | my ($maj, $min, $pkgrel) = $proxmox_ve->{OldVersion} =~ m/^(\d+)\.(\d+)[.-](\d+)/; |
a98193c2 | 196 | |
a98193c2 TL |
197 | if ($maj > $min_pve_major) { |
198 | log_pass("already upgraded to Proxmox VE " . ($min_pve_major + 1)); | |
199 | $upgraded = 1; | |
200 | } elsif ($maj >= $min_pve_major && $min >= $min_pve_minor && $pkgrel >= $min_pve_pkgrel) { | |
201 | log_pass("proxmox-ve package has version >= $min_pve_ver"); | |
202 | } else { | |
203 | log_fail("proxmox-ve package is too old, please upgrade to >= $min_pve_ver!"); | |
204 | } | |
205 | ||
ffa79167 | 206 | # FIXME: better differentiate between 6.2 from bullseye or bookworm |
fb59038a | 207 | my $kinstalled = 'proxmox-kernel-6.2'; |
a98193c2 TL |
208 | if (!$upgraded) { |
209 | # we got a few that avoided 5.15 in cluster with mixed CPUs, so allow older too | |
fb59038a | 210 | $kinstalled = 'pve-kernel-5.15'; |
a98193c2 TL |
211 | } |
212 | ||
fb59038a FE |
213 | my $kernel_version_is_expected = sub { |
214 | my ($version) = @_; | |
215 | ||
216 | return $version =~ m/^(?:5\.(?:13|15)|6\.2)/ if !$upgraded; | |
217 | ||
218 | if ($version =~ m/^6\.(?:2\.(?:[2-9]\d+|1[6-8]|1\d\d+)|5)[^~]*$/) { | |
219 | return 1; | |
220 | } elsif ($version =~ m/^(\d+).(\d+)[^~]*-pve$/) { | |
221 | return $1 >= 6 && $2 >= 2; | |
222 | } | |
223 | return 0; | |
224 | }; | |
225 | ||
a98193c2 TL |
226 | print "\nChecking running kernel version..\n"; |
227 | my $kernel_ver = $proxmox_ve->{RunningKernel}; | |
228 | if (!defined($kernel_ver)) { | |
229 | log_fail("unable to determine running kernel version."); | |
fb59038a | 230 | } elsif ($kernel_version_is_expected->($kernel_ver)) { |
a98193c2 TL |
231 | if ($upgraded) { |
232 | log_pass("running new kernel '$kernel_ver' after upgrade."); | |
233 | } else { | |
234 | log_pass("running kernel '$kernel_ver' is considered suitable for upgrade."); | |
235 | } | |
236 | } elsif ($get_pkg->($kinstalled)) { | |
237 | # with 6.2 kernel being available in both we might want to fine-tune the check? | |
8763c263 | 238 | log_warn("a suitable kernel ($kinstalled) is installed, but an unsuitable ($kernel_ver) is booted, missing reboot?!"); |
a98193c2 TL |
239 | } else { |
240 | log_warn("unexpected running and installed kernel '$kernel_ver'."); | |
241 | } | |
242 | ||
fb59038a | 243 | if ($upgraded && $kernel_version_is_expected->($kernel_ver)) { |
a98193c2 TL |
244 | my $outdated_kernel_meta_pkgs = []; |
245 | for my $kernel_meta_version ('5.4', '5.11', '5.13', '5.15') { | |
246 | my $pkg = "pve-kernel-${kernel_meta_version}"; | |
247 | if ($get_pkg->($pkg)) { | |
248 | push @$outdated_kernel_meta_pkgs, $pkg; | |
249 | } | |
250 | } | |
251 | if (scalar(@$outdated_kernel_meta_pkgs) > 0) { | |
252 | log_info( | |
253 | "Found outdated kernel meta-packages, taking up extra space on boot partitions.\n" | |
254 | ." After a successful upgrade, you can remove them using this command:\n" | |
255 | ." apt remove " . join(' ', $outdated_kernel_meta_pkgs->@*) | |
256 | ); | |
257 | } | |
258 | } | |
259 | } else { | |
260 | log_fail("proxmox-ve package not found!"); | |
261 | } | |
262 | } | |
263 | ||
264 | ||
265 | sub check_storage_health { | |
266 | print_header("CHECKING CONFIGURED STORAGES"); | |
267 | my $cfg = PVE::Storage::config(); | |
268 | ||
269 | my $ctime = time(); | |
270 | ||
271 | my $info = PVE::Storage::storage_info($cfg); | |
272 | ||
ffa79167 | 273 | for my $storeid (sort keys %$info) { |
a98193c2 TL |
274 | my $d = $info->{$storeid}; |
275 | if ($d->{enabled}) { | |
276 | if ($d->{active}) { | |
277 | log_pass("storage '$storeid' enabled and active."); | |
278 | } else { | |
279 | log_warn("storage '$storeid' enabled but not active!"); | |
280 | } | |
281 | } else { | |
282 | log_skip("storage '$storeid' disabled."); | |
283 | } | |
284 | } | |
285 | ||
286 | check_storage_content(); | |
eed1e93e TL |
287 | eval { check_storage_content_dirs() }; |
288 | log_fail("failed to check storage content directories - $@") if $@; | |
a98193c2 TL |
289 | } |
290 | ||
291 | sub check_cluster_corosync { | |
292 | print_header("CHECKING CLUSTER HEALTH/SETTINGS"); | |
293 | ||
294 | if (!PVE::Corosync::check_conf_exists(1)) { | |
295 | log_skip("standalone node."); | |
296 | return; | |
297 | } | |
298 | ||
299 | $log_systemd_unit_state->('pve-cluster.service'); | |
300 | $log_systemd_unit_state->('corosync.service'); | |
301 | ||
302 | if (PVE::Cluster::check_cfs_quorum(1)) { | |
303 | log_pass("Cluster Filesystem is quorate."); | |
304 | } else { | |
305 | log_fail("Cluster Filesystem readonly, lost quorum?!"); | |
306 | } | |
307 | ||
308 | my $conf = PVE::Cluster::cfs_read_file('corosync.conf'); | |
309 | my $conf_nodelist = PVE::Corosync::nodelist($conf); | |
310 | my $node_votes = 0; | |
311 | ||
312 | print "\nAnalzying quorum settings and state..\n"; | |
313 | if (!defined($conf_nodelist)) { | |
314 | log_fail("unable to retrieve nodelist from corosync.conf"); | |
315 | } else { | |
316 | if (grep { $conf_nodelist->{$_}->{quorum_votes} != 1 } keys %$conf_nodelist) { | |
317 | log_warn("non-default quorum_votes distribution detected!"); | |
318 | } | |
319 | map { $node_votes += $conf_nodelist->{$_}->{quorum_votes} // 0 } keys %$conf_nodelist; | |
320 | } | |
321 | ||
322 | my ($expected_votes, $total_votes); | |
323 | my $filter_output = sub { | |
324 | my $line = shift; | |
325 | ($expected_votes) = $line =~ /^Expected votes:\s*(\d+)\s*$/ | |
326 | if !defined($expected_votes); | |
327 | ($total_votes) = $line =~ /^Total votes:\s*(\d+)\s*$/ | |
328 | if !defined($total_votes); | |
329 | }; | |
330 | eval { | |
331 | run_command(['corosync-quorumtool', '-s'], outfunc => $filter_output, noerr => 1); | |
332 | }; | |
333 | ||
334 | if (!defined($expected_votes)) { | |
335 | log_fail("unable to get expected number of votes, assuming 0."); | |
336 | $expected_votes = 0; | |
337 | } | |
338 | if (!defined($total_votes)) { | |
339 | log_fail("unable to get expected number of votes, assuming 0."); | |
340 | $total_votes = 0; | |
341 | } | |
342 | ||
343 | my $cfs_nodelist = PVE::Cluster::get_clinfo()->{nodelist}; | |
344 | my $offline_nodes = grep { $cfs_nodelist->{$_}->{online} != 1 } keys %$cfs_nodelist; | |
345 | if ($offline_nodes > 0) { | |
346 | log_fail("$offline_nodes nodes are offline!"); | |
347 | } | |
348 | ||
349 | my $qdevice_votes = 0; | |
350 | if (my $qdevice_setup = $conf->{main}->{quorum}->{device}) { | |
351 | $qdevice_votes = $qdevice_setup->{votes} // 1; | |
352 | } | |
353 | ||
354 | log_info("configured votes - nodes: $node_votes"); | |
355 | log_info("configured votes - qdevice: $qdevice_votes"); | |
356 | log_info("current expected votes: $expected_votes"); | |
357 | log_info("current total votes: $total_votes"); | |
358 | ||
359 | log_warn("expected votes set to non-standard value '$expected_votes'.") | |
360 | if $expected_votes != $node_votes + $qdevice_votes; | |
361 | log_warn("total votes < expected votes: $total_votes/$expected_votes!") | |
362 | if $total_votes < $expected_votes; | |
363 | ||
364 | my $conf_nodelist_count = scalar(keys %$conf_nodelist); | |
365 | my $cfs_nodelist_count = scalar(keys %$cfs_nodelist); | |
366 | log_warn("cluster consists of less than three quorum-providing nodes!") | |
367 | if $conf_nodelist_count < 3 && $conf_nodelist_count + $qdevice_votes < 3; | |
368 | ||
369 | log_fail("corosync.conf ($conf_nodelist_count) and pmxcfs ($cfs_nodelist_count) don't agree about size of nodelist.") | |
370 | if $conf_nodelist_count != $cfs_nodelist_count; | |
371 | ||
372 | print "\nChecking nodelist entries..\n"; | |
373 | my $nodelist_pass = 1; | |
374 | for my $cs_node (sort keys %$conf_nodelist) { | |
375 | my $entry = $conf_nodelist->{$cs_node}; | |
376 | if (!defined($entry->{name})) { | |
377 | $nodelist_pass = 0; | |
378 | log_fail("$cs_node: no name entry in corosync.conf."); | |
379 | } | |
380 | if (!defined($entry->{nodeid})) { | |
381 | $nodelist_pass = 0; | |
382 | log_fail("$cs_node: no nodeid configured in corosync.conf."); | |
383 | } | |
384 | my $gotLinks = 0; | |
385 | for my $link (0..7) { | |
386 | $gotLinks++ if defined($entry->{"ring${link}_addr"}); | |
387 | } | |
388 | if ($gotLinks <= 0) { | |
389 | $nodelist_pass = 0; | |
390 | log_fail("$cs_node: no ringX_addr (0 <= X <= 7) link defined in corosync.conf."); | |
391 | } | |
392 | ||
393 | my $verify_ring_ip = sub { | |
394 | my $key = shift; | |
395 | if (defined(my $ring = $entry->{$key})) { | |
396 | my ($resolved_ip, undef) = PVE::Corosync::resolve_hostname_like_corosync($ring, $conf); | |
397 | if (defined($resolved_ip)) { | |
398 | if ($resolved_ip ne $ring) { | |
399 | $nodelist_pass = 0; | |
400 | log_warn( | |
401 | "$cs_node: $key '$ring' resolves to '$resolved_ip'.\n" | |
402 | ." Consider replacing it with the currently resolved IP address." | |
403 | ); | |
404 | } | |
405 | } else { | |
406 | $nodelist_pass = 0; | |
407 | log_fail( | |
408 | "$cs_node: unable to resolve $key '$ring' to an IP address according to Corosync's" | |
409 | ." resolve strategy - cluster will potentially fail with Corosync 3.x/kronosnet!" | |
410 | ); | |
411 | } | |
412 | } | |
413 | }; | |
414 | for my $link (0..7) { | |
415 | $verify_ring_ip->("ring${link}_addr"); | |
416 | } | |
417 | } | |
418 | log_pass("nodelist settings OK") if $nodelist_pass; | |
419 | ||
420 | print "\nChecking totem settings..\n"; | |
421 | my $totem = $conf->{main}->{totem}; | |
422 | my $totem_pass = 1; | |
423 | ||
424 | my $transport = $totem->{transport}; | |
425 | if (defined($transport)) { | |
426 | if ($transport ne 'knet') { | |
427 | $totem_pass = 0; | |
428 | log_fail("Corosync transport explicitly set to '$transport' instead of implicit default!"); | |
429 | } | |
430 | } | |
431 | ||
432 | # TODO: are those values still up-to-date? | |
433 | if ((!defined($totem->{secauth}) || $totem->{secauth} ne 'on') && (!defined($totem->{crypto_cipher}) || $totem->{crypto_cipher} eq 'none')) { | |
434 | $totem_pass = 0; | |
435 | log_fail("Corosync authentication/encryption is not explicitly enabled (secauth / crypto_cipher / crypto_hash)!"); | |
436 | } elsif (defined($totem->{crypto_cipher}) && $totem->{crypto_cipher} eq '3des') { | |
437 | $totem_pass = 0; | |
438 | log_fail("Corosync encryption cipher set to '3des', no longer supported in Corosync 3.x!"); # FIXME: can be removed? | |
439 | } | |
440 | ||
441 | log_pass("totem settings OK") if $totem_pass; | |
442 | print "\n"; | |
443 | log_info("run 'pvecm status' to get detailed cluster status.."); | |
444 | ||
445 | if (defined(my $corosync = $get_pkg->('corosync'))) { | |
446 | if ($corosync->{OldVersion} =~ m/^2\./) { | |
447 | log_fail("\ncorosync 2.x installed, cluster-wide upgrade to 3.x needed!"); | |
448 | } elsif ($corosync->{OldVersion} !~ m/^3\./) { | |
449 | log_fail("\nunexpected corosync version installed: $corosync->{OldVersion}!"); | |
450 | } | |
451 | } | |
452 | } | |
453 | ||
454 | sub check_ceph { | |
455 | print_header("CHECKING HYPER-CONVERGED CEPH STATUS"); | |
456 | ||
457 | if (PVE::Ceph::Tools::check_ceph_inited(1)) { | |
458 | log_info("hyper-converged ceph setup detected!"); | |
459 | } else { | |
460 | log_skip("no hyper-converged ceph setup detected!"); | |
461 | return; | |
462 | } | |
463 | ||
464 | log_info("getting Ceph status/health information.."); | |
465 | my $ceph_status = eval { PVE::API2::Ceph->status({ node => $nodename }); }; | |
466 | my $noout = eval { PVE::API2::Cluster::Ceph->get_flag({ flag => "noout" }); }; | |
467 | if ($@) { | |
468 | log_fail("failed to get 'noout' flag status - $@"); | |
469 | } | |
470 | ||
471 | my $noout_wanted = 1; | |
472 | ||
473 | if (!$ceph_status || !$ceph_status->{health}) { | |
474 | log_fail("unable to determine Ceph status!"); | |
475 | } else { | |
476 | my $ceph_health = $ceph_status->{health}->{status}; | |
477 | if (!$ceph_health) { | |
478 | log_fail("unable to determine Ceph health!"); | |
479 | } elsif ($ceph_health eq 'HEALTH_OK') { | |
480 | log_pass("Ceph health reported as 'HEALTH_OK'."); | |
481 | } elsif ($ceph_health eq 'HEALTH_WARN' && $noout && (keys %{$ceph_status->{health}->{checks}} == 1)) { | |
482 | log_pass("Ceph health reported as 'HEALTH_WARN' with a single failing check and 'noout' flag set."); | |
483 | } else { | |
484 | log_warn( | |
485 | "Ceph health reported as '$ceph_health'.\n Use the PVE dashboard or 'ceph -s'" | |
486 | ." to determine the specific issues and try to resolve them." | |
487 | ); | |
488 | } | |
489 | } | |
490 | ||
491 | # TODO: check OSD min-required version, if to low it breaks stuff! | |
492 | ||
eed1e93e | 493 | log_info("checking local Ceph version.."); |
a98193c2 TL |
494 | if (my $release = eval { PVE::Ceph::Tools::get_local_version(1) }) { |
495 | my $code_name = $ceph_release2code->{"$release"} || 'unknown'; | |
496 | if ($release == $ceph_supported_release) { | |
497 | log_pass("found expected Ceph $ceph_supported_release $ceph_supported_code_name release.") | |
498 | } elsif ($release > $ceph_supported_release) { | |
499 | log_warn( | |
500 | "found newer Ceph release $release $code_name as the expected $ceph_supported_release" | |
501 | ." $ceph_supported_code_name, installed third party repos?!" | |
502 | ) | |
503 | } else { | |
504 | log_fail( | |
505 | "Hyper-converged Ceph $release $code_name is to old for upgrade!\n" | |
506 | ." Upgrade Ceph first to $ceph_supported_code_name following our how-to:\n" | |
507 | ." <https://pve.proxmox.com/wiki/Category:Ceph_Upgrade>" | |
508 | ); | |
509 | } | |
510 | } else { | |
511 | log_fail("unable to determine local Ceph version!"); | |
512 | } | |
513 | ||
514 | log_info("getting Ceph daemon versions.."); | |
515 | my $ceph_versions = eval { PVE::Ceph::Tools::get_cluster_versions(undef, 1); }; | |
516 | if (!$ceph_versions) { | |
517 | log_fail("unable to determine Ceph daemon versions!"); | |
518 | } else { | |
519 | my $services = [ | |
520 | { 'key' => 'mon', 'name' => 'monitor' }, | |
521 | { 'key' => 'mgr', 'name' => 'manager' }, | |
522 | { 'key' => 'mds', 'name' => 'MDS' }, | |
523 | { 'key' => 'osd', 'name' => 'OSD' }, | |
524 | ]; | |
525 | ||
eed1e93e TL |
526 | my $ceph_versions_simple = {}; |
527 | my $ceph_versions_commits = {}; | |
528 | for my $type (keys %$ceph_versions) { | |
529 | for my $full_version (keys $ceph_versions->{$type}->%*) { | |
530 | if ($full_version =~ m/^(.*) \((.*)\).*\(.*\)$/) { | |
531 | # String is in the form of | |
532 | # ceph version 17.2.6 (810db68029296377607028a6c6da1ec06f5a2b27) quincy (stable) | |
533 | # only check the first part, e.g. 'ceph version 17.2.6', the commit hash can | |
534 | # be different | |
535 | $ceph_versions_simple->{$type}->{$1} = 1; | |
536 | $ceph_versions_commits->{$type}->{$2} = 1; | |
537 | } | |
538 | } | |
539 | } | |
540 | ||
ffa79167 | 541 | for my $service (@$services) { |
a98193c2 | 542 | my ($name, $key) = $service->@{'name', 'key'}; |
eed1e93e | 543 | if (my $service_versions = $ceph_versions_simple->{$key}) { |
a98193c2 TL |
544 | if (keys %$service_versions == 0) { |
545 | log_skip("no running instances detected for daemon type $name."); | |
546 | } elsif (keys %$service_versions == 1) { | |
547 | log_pass("single running version detected for daemon type $name."); | |
548 | } else { | |
549 | log_warn("multiple running versions detected for daemon type $name!"); | |
550 | } | |
551 | } else { | |
552 | log_skip("unable to determine versions of running Ceph $name instances."); | |
553 | } | |
eed1e93e TL |
554 | my $service_commits = $ceph_versions_commits->{$key}; |
555 | log_info("different builds of same version detected for an $name. Are you in the middle of the upgrade?") | |
556 | if $service_commits && keys %$service_commits > 1; | |
a98193c2 TL |
557 | } |
558 | ||
559 | my $overall_versions = $ceph_versions->{overall}; | |
560 | if (!$overall_versions) { | |
561 | log_warn("unable to determine overall Ceph daemon versions!"); | |
562 | } elsif (keys %$overall_versions == 1) { | |
563 | log_pass("single running overall version detected for all Ceph daemon types."); | |
a083d410 | 564 | $noout_wanted = !$upgraded; # off post-upgrade, on pre-upgrade |
eed1e93e | 565 | } elsif (keys $ceph_versions_simple->{overall}->%* != 1) { |
a98193c2 TL |
566 | log_warn("overall version mismatch detected, check 'ceph versions' output for details!"); |
567 | } | |
568 | } | |
569 | ||
570 | if ($noout) { | |
571 | if ($noout_wanted) { | |
572 | log_pass("'noout' flag set to prevent rebalancing during cluster-wide upgrades."); | |
573 | } else { | |
574 | log_warn("'noout' flag set, Ceph cluster upgrade seems finished."); | |
575 | } | |
576 | } elsif ($noout_wanted) { | |
577 | log_warn("'noout' flag not set - recommended to prevent rebalancing during upgrades."); | |
578 | } | |
579 | ||
580 | log_info("checking Ceph config.."); | |
581 | my $conf = PVE::Cluster::cfs_read_file('ceph.conf'); | |
582 | if (%$conf) { | |
583 | my $global = $conf->{global}; | |
584 | ||
585 | my $global_monhost = $global->{mon_host} // $global->{"mon host"} // $global->{"mon-host"}; | |
586 | if (!defined($global_monhost)) { | |
587 | log_warn( | |
588 | "No 'mon_host' entry found in ceph config.\n It's recommended to add mon_host with" | |
589 | ." all monitor addresses (without ports) to the global section." | |
590 | ); | |
591 | } | |
592 | ||
593 | my $ipv6 = $global->{ms_bind_ipv6} // $global->{"ms bind ipv6"} // $global->{"ms-bind-ipv6"}; | |
594 | if ($ipv6) { | |
595 | my $ipv4 = $global->{ms_bind_ipv4} // $global->{"ms bind ipv4"} // $global->{"ms-bind-ipv4"}; | |
596 | if ($ipv6 eq 'true' && (!defined($ipv4) || $ipv4 ne 'false')) { | |
597 | log_warn( | |
598 | "'ms_bind_ipv6' is enabled but 'ms_bind_ipv4' is not disabled.\n Make sure to" | |
599 | ." disable 'ms_bind_ipv4' for ipv6 only clusters, or add an ipv4 network to public/cluster network." | |
600 | ); | |
601 | } | |
602 | } | |
603 | ||
604 | if (defined($global->{keyring})) { | |
605 | log_warn( | |
606 | "[global] config section contains 'keyring' option, which will prevent services from" | |
607 | ." starting with Nautilus.\n Move 'keyring' option to [client] section instead." | |
608 | ); | |
609 | } | |
610 | ||
611 | } else { | |
612 | log_warn("Empty ceph config found"); | |
613 | } | |
614 | ||
615 | my $local_ceph_ver = PVE::Ceph::Tools::get_local_version(1); | |
616 | if (defined($local_ceph_ver)) { | |
617 | if ($local_ceph_ver <= 14) { | |
618 | log_fail("local Ceph version too low, at least Octopus required.."); | |
619 | } | |
620 | } else { | |
621 | log_fail("unable to determine local Ceph version."); | |
622 | } | |
623 | } | |
624 | ||
625 | sub check_backup_retention_settings { | |
626 | log_info("Checking backup retention settings.."); | |
627 | ||
628 | my $pass = 1; | |
629 | ||
a98193c2 TL |
630 | my $maxfiles_msg = "parameter 'maxfiles' is deprecated with PVE 7.x and will be removed in a " . |
631 | "future version, use 'prune-backups' instead."; | |
632 | ||
633 | eval { | |
634 | my $confdesc = PVE::VZDump::Common::get_confdesc(); | |
daf74a20 FE |
635 | # vzdump.conf by itself doesn't need to honor any 'requires' |
636 | delete $confdesc->{$_}->{requires} for keys $confdesc->%*; | |
a98193c2 TL |
637 | |
638 | my $fn = "/etc/vzdump.conf"; | |
639 | my $raw = PVE::Tools::file_get_contents($fn); | |
640 | ||
641 | my $conf_schema = { type => 'object', properties => $confdesc, }; | |
642 | my $param = PVE::JSONSchema::parse_config($conf_schema, $fn, $raw); | |
643 | ||
644 | if (defined($param->{maxfiles})) { | |
645 | $pass = 0; | |
646 | log_warn("$fn - $maxfiles_msg"); | |
647 | } | |
a98193c2 TL |
648 | }; |
649 | if (my $err = $@) { | |
650 | $pass = 0; | |
651 | log_warn("unable to parse node's VZDump configuration - $err"); | |
652 | } | |
653 | ||
654 | my $storage_cfg = PVE::Storage::config(); | |
655 | ||
656 | for my $storeid (keys $storage_cfg->{ids}->%*) { | |
657 | my $scfg = $storage_cfg->{ids}->{$storeid}; | |
658 | ||
659 | if (defined($scfg->{maxfiles})) { | |
660 | $pass = 0; | |
661 | log_warn("storage '$storeid' - $maxfiles_msg"); | |
662 | } | |
a98193c2 TL |
663 | } |
664 | ||
665 | eval { | |
666 | my $vzdump_cron = PVE::Cluster::cfs_read_file('vzdump.cron'); | |
667 | ||
668 | # only warn once, there might be many jobs... | |
669 | if (scalar(grep { defined($_->{maxfiles}) } $vzdump_cron->{jobs}->@*)) { | |
670 | $pass = 0; | |
671 | log_warn("/etc/pve/vzdump.cron - $maxfiles_msg"); | |
672 | } | |
673 | }; | |
674 | if (my $err = $@) { | |
675 | $pass = 0; | |
676 | log_warn("unable to parse node's VZDump configuration - $err"); | |
677 | } | |
678 | ||
eed1e93e | 679 | log_pass("no backup retention problems found.") if $pass; |
a98193c2 TL |
680 | } |
681 | ||
682 | sub check_cifs_credential_location { | |
683 | log_info("checking CIFS credential location.."); | |
684 | ||
685 | my $regex = qr/^(.*)\.cred$/; | |
686 | ||
687 | my $found; | |
688 | ||
689 | PVE::Tools::dir_glob_foreach('/etc/pve/priv/', $regex, sub { | |
690 | my ($filename) = @_; | |
691 | ||
692 | my ($basename) = $filename =~ $regex; | |
693 | ||
694 | log_warn( | |
695 | "CIFS credentials '/etc/pve/priv/$filename' will be moved to" | |
696 | ." '/etc/pve/priv/storage/$basename.pw' during the update" | |
697 | ); | |
698 | ||
699 | $found = 1; | |
700 | }); | |
701 | ||
702 | log_pass("no CIFS credentials at outdated location found.") if !$found; | |
703 | } | |
704 | ||
705 | sub check_custom_pool_roles { | |
ffa79167 | 706 | log_info("Checking permission system changes.."); |
a98193c2 TL |
707 | |
708 | if (! -f "/etc/pve/user.cfg") { | |
709 | log_skip("user.cfg does not exist"); | |
710 | return; | |
711 | } | |
712 | ||
713 | my $raw = eval { PVE::Tools::file_get_contents('/etc/pve/user.cfg'); }; | |
714 | if ($@) { | |
715 | log_fail("Failed to read '/etc/pve/user.cfg' - $@"); | |
716 | return; | |
717 | } | |
718 | ||
719 | my $roles = {}; | |
720 | while ($raw =~ /^\s*(.+?)\s*$/gm) { | |
721 | my $line = $1; | |
722 | my @data; | |
723 | ||
ffa79167 | 724 | for my $d (split (/:/, $line)) { |
a98193c2 TL |
725 | $d =~ s/^\s+//; |
726 | $d =~ s/\s+$//; | |
727 | push @data, $d | |
728 | } | |
729 | ||
730 | my $et = shift @data; | |
ffa79167 TL |
731 | if ($et eq 'role') { |
732 | my ($role, $privlist) = @data; | |
733 | if (!PVE::AccessControl::verify_rolename($role, 1)) { | |
734 | warn "user config - ignore role '$role' - invalid characters in role name\n"; | |
735 | next; | |
736 | } | |
a98193c2 | 737 | |
ffa79167 TL |
738 | $roles->{$role} = {} if !$roles->{$role}; |
739 | for my $priv (split_list($privlist)) { | |
740 | $roles->{$role}->{$priv} = 1; | |
741 | } | |
742 | } elsif ($et eq 'acl') { | |
743 | my ($propagate, $pathtxt, $uglist, $rolelist) = @data; | |
744 | for my $role (split_list($rolelist)) { | |
745 | if ($role eq 'PVESysAdmin' || $role eq 'PVEAdmin') { | |
746 | log_warn( | |
747 | "found ACL entry on '$pathtxt' for '$uglist' with role '$role' - this role" | |
748 | ." will no longer have 'Permissions.Modify' after the upgrade!" | |
749 | ); | |
750 | } | |
751 | } | |
a98193c2 TL |
752 | } |
753 | } | |
754 | ||
ffa79167 | 755 | log_info("Checking custom role IDs for clashes with new 'PVE' namespace.."); |
eed1e93e TL |
756 | my ($custom_roles, $pve_namespace_clashes) = (0, 0); |
757 | for my $role (sort keys %{$roles}) { | |
a98193c2 | 758 | next if PVE::AccessControl::role_is_special($role); |
eed1e93e | 759 | $custom_roles++; |
a98193c2 | 760 | |
eed1e93e TL |
761 | if ($role =~ /^PVE/i) { |
762 | log_warn("custom role '$role' clashes with 'PVE' namespace for built-in roles"); | |
763 | $pve_namespace_clashes++; | |
764 | } | |
765 | } | |
766 | if ($pve_namespace_clashes > 0) { | |
767 | log_fail("$pve_namespace_clashes custom role(s) will clash with 'PVE' namespace for built-in roles enforced in Proxmox VE 8"); | |
768 | } elsif ($custom_roles > 0) { | |
769 | log_pass("none of the $custom_roles custom roles will clash with newly enforced 'PVE' namespace") | |
770 | } else { | |
771 | log_pass("no custom roles defined, so no clash with 'PVE' role ID namespace enforced in Proxmox VE 8") | |
a98193c2 TL |
772 | } |
773 | } | |
774 | ||
775 | my sub check_max_length { | |
776 | my ($raw, $max_length, $warning) = @_; | |
777 | log_warn($warning) if defined($raw) && length($raw) > $max_length; | |
778 | } | |
779 | ||
780 | sub check_node_and_guest_configurations { | |
eed1e93e | 781 | log_info("Checking node and guest description/note length.."); |
a98193c2 TL |
782 | |
783 | my @affected_nodes = grep { | |
784 | my $desc = PVE::NodeConfig::load_config($_)->{desc}; | |
785 | defined($desc) && length($desc) > 64 * 1024 | |
786 | } PVE::Cluster::get_nodelist(); | |
787 | ||
788 | if (scalar(@affected_nodes) > 0) { | |
789 | log_warn("Node config description of the following nodes too long for new limit of 64 KiB:\n " | |
790 | . join(', ', @affected_nodes)); | |
791 | } else { | |
792 | log_pass("All node config descriptions fit in the new limit of 64 KiB"); | |
793 | } | |
794 | ||
795 | my $affected_guests_long_desc = []; | |
796 | my $affected_cts_cgroup_keys = []; | |
797 | ||
798 | my $cts = PVE::LXC::config_list(); | |
799 | for my $vmid (sort { $a <=> $b } keys %$cts) { | |
800 | my $conf = PVE::LXC::Config->load_config($vmid); | |
801 | ||
802 | my $desc = $conf->{description}; | |
803 | push @$affected_guests_long_desc, "CT $vmid" if defined($desc) && length($desc) > 8 * 1024; | |
804 | ||
805 | my $lxc_raw_conf = $conf->{lxc}; | |
806 | push @$affected_cts_cgroup_keys, "CT $vmid" if (grep (@$_[0] =~ /^lxc\.cgroup\./, @$lxc_raw_conf)); | |
807 | } | |
808 | my $vms = PVE::QemuServer::config_list(); | |
809 | for my $vmid (sort { $a <=> $b } keys %$vms) { | |
810 | my $desc = PVE::QemuConfig->load_config($vmid)->{description}; | |
811 | push @$affected_guests_long_desc, "VM $vmid" if defined($desc) && length($desc) > 8 * 1024; | |
812 | } | |
813 | if (scalar($affected_guests_long_desc->@*) > 0) { | |
814 | log_warn("Guest config description of the following virtual-guests too long for new limit of 64 KiB:\n" | |
815 | ." " . join(", ", $affected_guests_long_desc->@*)); | |
816 | } else { | |
817 | log_pass("All guest config descriptions fit in the new limit of 8 KiB"); | |
818 | } | |
819 | ||
820 | log_info("Checking container configs for deprecated lxc.cgroup entries"); | |
821 | ||
822 | if (scalar($affected_cts_cgroup_keys->@*) > 0) { | |
823 | if ($forced_legacy_cgroup) { | |
824 | log_pass("Found legacy 'lxc.cgroup' keys, but system explicitly configured for legacy hybrid cgroup hierarchy."); | |
825 | } else { | |
826 | log_warn("The following CTs have 'lxc.cgroup' keys configured, which will be ignored in the new default unified cgroupv2:\n" | |
827 | ." " . join(", ", $affected_cts_cgroup_keys->@*) ."\n" | |
828 | ." Often it can be enough to change to the new 'lxc.cgroup2' prefix after the upgrade to Proxmox VE 7.x"); | |
829 | } | |
830 | } else { | |
831 | log_pass("No legacy 'lxc.cgroup' keys found."); | |
832 | } | |
833 | } | |
834 | ||
835 | sub check_storage_content { | |
836 | log_info("Checking storage content type configuration.."); | |
837 | ||
838 | my $found; | |
839 | my $pass = 1; | |
840 | ||
841 | my $storage_cfg = PVE::Storage::config(); | |
842 | ||
843 | for my $storeid (sort keys $storage_cfg->{ids}->%*) { | |
844 | my $scfg = $storage_cfg->{ids}->{$storeid}; | |
845 | ||
846 | next if $scfg->{shared}; | |
847 | next if !PVE::Storage::storage_check_enabled($storage_cfg, $storeid, undef, 1); | |
848 | ||
849 | my $valid_content = PVE::Storage::Plugin::valid_content_types($scfg->{type}); | |
850 | ||
851 | if (scalar(keys $scfg->{content}->%*) == 0 && !$valid_content->{none}) { | |
852 | $pass = 0; | |
853 | log_fail("storage '$storeid' does not support configured content type 'none'"); | |
854 | delete $scfg->{content}->{none}; # scan for guest images below | |
855 | } | |
856 | ||
857 | next if $scfg->{content}->{images}; | |
858 | next if $scfg->{content}->{rootdir}; | |
859 | ||
eed1e93e | 860 | # Skip 'iscsi(direct)' (and foreign plugins with potentially similar behavior) with 'none', |
a98193c2 TL |
861 | # because that means "use LUNs directly" and vdisk_list() in PVE 6.x still lists those. |
862 | # It's enough to *not* skip 'dir', because it is the only other storage that supports 'none' | |
863 | # and 'images' or 'rootdir', hence being potentially misconfigured. | |
864 | next if $scfg->{type} ne 'dir' && $scfg->{content}->{none}; | |
865 | ||
866 | eval { PVE::Storage::activate_storage($storage_cfg, $storeid) }; | |
867 | if (my $err = $@) { | |
868 | log_warn("activating '$storeid' failed - $err"); | |
869 | next; | |
870 | } | |
871 | ||
872 | my $res = eval { PVE::Storage::vdisk_list($storage_cfg, $storeid); }; | |
873 | if (my $err = $@) { | |
874 | log_warn("listing images on '$storeid' failed - $err"); | |
875 | next; | |
876 | } | |
877 | my @volids = map { $_->{volid} } $res->{$storeid}->@*; | |
878 | ||
879 | my $number = scalar(@volids); | |
880 | if ($number > 0) { | |
881 | log_info( | |
882 | "storage '$storeid' - neither content type 'images' nor 'rootdir' configured, but" | |
883 | ."found $number guest volume(s)" | |
884 | ); | |
885 | } | |
886 | } | |
887 | ||
888 | my $check_volid = sub { | |
889 | my ($volid, $vmid, $vmtype, $reference) = @_; | |
890 | ||
891 | my $guesttext = $vmtype eq 'qemu' ? 'VM' : 'CT'; | |
892 | my $prefix = "$guesttext $vmid - volume '$volid' ($reference)"; | |
893 | ||
894 | my ($storeid) = PVE::Storage::parse_volume_id($volid, 1); | |
895 | return if !defined($storeid); | |
896 | ||
897 | my $scfg = $storage_cfg->{ids}->{$storeid}; | |
898 | if (!$scfg) { | |
899 | $pass = 0; | |
900 | log_warn("$prefix - storage does not exist!"); | |
901 | return; | |
902 | } | |
903 | ||
904 | # cannot use parse_volname for containers, as it can return 'images' | |
905 | # but containers cannot have ISO images attached, so assume 'rootdir' | |
906 | my $vtype = 'rootdir'; | |
907 | if ($vmtype eq 'qemu') { | |
908 | ($vtype) = eval { PVE::Storage::parse_volname($storage_cfg, $volid); }; | |
909 | return if $@; | |
910 | } | |
911 | ||
912 | if (!$scfg->{content}->{$vtype}) { | |
913 | $found = 1; | |
914 | $pass = 0; | |
915 | log_warn("$prefix - storage does not have content type '$vtype' configured."); | |
916 | } | |
917 | }; | |
918 | ||
919 | my $cts = PVE::LXC::config_list(); | |
920 | for my $vmid (sort { $a <=> $b } keys %$cts) { | |
921 | my $conf = PVE::LXC::Config->load_config($vmid); | |
922 | ||
923 | my $volhash = {}; | |
924 | ||
925 | my $check = sub { | |
926 | my ($ms, $mountpoint, $reference) = @_; | |
927 | ||
928 | my $volid = $mountpoint->{volume}; | |
929 | return if !$volid || $mountpoint->{type} ne 'volume'; | |
930 | ||
931 | return if $volhash->{$volid}; # volume might be referenced multiple times | |
932 | ||
933 | $volhash->{$volid} = 1; | |
934 | ||
935 | $check_volid->($volid, $vmid, 'lxc', $reference); | |
936 | }; | |
937 | ||
938 | my $opts = { include_unused => 1 }; | |
939 | PVE::LXC::Config->foreach_volume_full($conf, $opts, $check, 'in config'); | |
940 | for my $snapname (keys $conf->{snapshots}->%*) { | |
941 | my $snap = $conf->{snapshots}->{$snapname}; | |
942 | PVE::LXC::Config->foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'"); | |
943 | } | |
944 | } | |
945 | ||
946 | my $vms = PVE::QemuServer::config_list(); | |
947 | for my $vmid (sort { $a <=> $b } keys %$vms) { | |
948 | my $conf = PVE::QemuConfig->load_config($vmid); | |
949 | ||
950 | my $volhash = {}; | |
951 | ||
952 | my $check = sub { | |
953 | my ($key, $drive, $reference) = @_; | |
954 | ||
955 | my $volid = $drive->{file}; | |
956 | return if $volid =~ m|^/|; | |
957 | return if $volhash->{$volid}; # volume might be referenced multiple times | |
958 | ||
959 | $volhash->{$volid} = 1; | |
960 | $check_volid->($volid, $vmid, 'qemu', $reference); | |
961 | }; | |
962 | ||
963 | my $opts = { | |
964 | extra_keys => ['vmstate'], | |
965 | include_unused => 1, | |
966 | }; | |
967 | # startup from a suspended state works even without 'images' content type on the | |
968 | # state storage, so do not check 'vmstate' for $conf | |
969 | PVE::QemuConfig->foreach_volume_full($conf, { include_unused => 1 }, $check, 'in config'); | |
970 | for my $snapname (keys $conf->{snapshots}->%*) { | |
971 | my $snap = $conf->{snapshots}->{$snapname}; | |
972 | PVE::QemuConfig->foreach_volume_full($snap, $opts, $check, "in snapshot '$snapname'"); | |
973 | } | |
974 | } | |
975 | ||
976 | if ($found) { | |
977 | log_warn("Proxmox VE enforces stricter content type checks since 7.0. The guests above " . | |
978 | "might not work until the storage configuration is fixed."); | |
979 | } | |
980 | ||
981 | if ($pass) { | |
eed1e93e TL |
982 | log_pass("no storage content problems found"); |
983 | } | |
984 | } | |
985 | ||
986 | sub check_storage_content_dirs { | |
987 | my $storage_cfg = PVE::Storage::config(); | |
988 | ||
989 | # check that content dirs are pairwise inequal | |
990 | my $any_problematic = 0; | |
991 | for my $storeid (sort keys $storage_cfg->{ids}->%*) { | |
992 | my $scfg = $storage_cfg->{ids}->{$storeid}; | |
993 | ||
994 | next if !PVE::Storage::storage_check_enabled($storage_cfg, $storeid, undef, 1); | |
995 | next if !$scfg->{path} || !$scfg->{content}; | |
996 | ||
997 | eval { PVE::Storage::activate_storage($storage_cfg, $storeid) }; | |
998 | if (my $err = $@) { | |
999 | log_warn("activating '$storeid' failed - $err"); | |
1000 | next; | |
1001 | } | |
1002 | ||
1003 | my $resolved_subdirs = {}; | |
1004 | my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); | |
1005 | for my $vtype (keys $scfg->{content}->%*) { | |
1006 | my $abs_subdir = Cwd::abs_path($plugin->get_subdir($scfg, $vtype)); | |
2a7f4f71 | 1007 | next if !defined($abs_subdir); |
eed1e93e TL |
1008 | push $resolved_subdirs->{$abs_subdir}->@*, $vtype; |
1009 | } | |
1010 | for my $subdir (keys $resolved_subdirs->%*) { | |
1011 | if (scalar($resolved_subdirs->{$subdir}->@*) > 1) { | |
1012 | my $types = join(", ", $resolved_subdirs->{$subdir}->@*); | |
1013 | log_warn("storage '$storeid' uses directory $subdir for multiple content types ($types)."); | |
1014 | $any_problematic = 1; | |
1015 | } | |
1016 | } | |
1017 | } | |
1018 | if ($any_problematic) { | |
1019 | log_fail("re-using directory for multiple content types (see above) is no longer supported in Proxmox VE 8!") | |
1020 | } else { | |
1021 | log_pass("no storage re-uses a directory for multiple content types.") | |
a98193c2 TL |
1022 | } |
1023 | } | |
1024 | ||
1025 | sub check_containers_cgroup_compat { | |
1026 | if ($forced_legacy_cgroup) { | |
1027 | log_warn("System explicitly configured for legacy hybrid cgroup hierarchy.\n" | |
eed1e93e | 1028 | ." NOTE: support for the hybrid cgroup hierarchy will be removed in future Proxmox VE 9 (~ 2025)." |
a98193c2 TL |
1029 | ); |
1030 | } | |
1031 | ||
1032 | my $supports_cgroupv2 = sub { | |
1033 | my ($conf, $rootdir, $ctid) = @_; | |
1034 | ||
1035 | my $get_systemd_version = sub { | |
1036 | my ($self) = @_; | |
1037 | ||
68278ea3 CE |
1038 | my @dirs = ( |
1039 | '/lib/systemd', | |
1040 | '/usr/lib/systemd', | |
1041 | '/usr/lib/x86_64-linux-gnu/systemd', | |
1042 | '/usr/lib64/systemd' | |
1043 | ); | |
ffa79167 | 1044 | my $libsd; |
68278ea3 | 1045 | for my $dir (@dirs) { |
ffa79167 TL |
1046 | $libsd = PVE::Tools::dir_glob_regex($dir, "libsystemd-shared-.+\.so"); |
1047 | last if defined($libsd); | |
1048 | } | |
68278ea3 | 1049 | if (defined($libsd) && $libsd =~ /libsystemd-shared-(\d+)(\.\d-\d)?(\.fc\d\d)?\.so/) { |
a98193c2 TL |
1050 | return $1; |
1051 | } | |
1052 | ||
1053 | return undef; | |
1054 | }; | |
1055 | ||
1056 | my $unified_cgroupv2_support = sub { | |
1057 | my ($self) = @_; | |
1058 | ||
1059 | # https://www.freedesktop.org/software/systemd/man/systemd.html | |
1060 | # systemd is installed as symlink to /sbin/init | |
1061 | my $systemd = CORE::readlink('/sbin/init'); | |
1062 | ||
1063 | # assume non-systemd init will run with unified cgroupv2 | |
1064 | if (!defined($systemd) || $systemd !~ m@/systemd$@) { | |
1065 | return 1; | |
1066 | } | |
1067 | ||
1068 | # systemd version 232 (e.g. debian stretch) supports the unified hierarchy | |
1069 | my $sdver = $get_systemd_version->(); | |
1070 | if (!defined($sdver) || $sdver < 232) { | |
1071 | return 0; | |
1072 | } | |
1073 | ||
1074 | return 1; | |
1075 | }; | |
1076 | ||
1077 | my $ostype = $conf->{ostype}; | |
1078 | if (!defined($ostype)) { | |
1079 | log_warn("Found CT ($ctid) without 'ostype' set!"); | |
1080 | } elsif ($ostype eq 'devuan' || $ostype eq 'alpine') { | |
1081 | return 1; # no systemd, no cgroup problems | |
1082 | } | |
1083 | ||
1084 | my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); | |
1085 | return $lxc_setup->protected_call($unified_cgroupv2_support); | |
1086 | }; | |
1087 | ||
1088 | my $log_problem = sub { | |
1089 | my ($ctid) = @_; | |
1090 | my $extra = $forced_legacy_cgroup ? '' : " or set systemd.unified_cgroup_hierarchy=0 in the Proxmox VE hosts' kernel cmdline"; | |
1091 | log_warn( | |
1092 | "Found at least one CT ($ctid) which does not support running in a unified cgroup v2 layout\n" | |
1093 | ." Consider upgrading the Containers distro${extra}! Skipping further CT compat checks." | |
1094 | ); | |
1095 | }; | |
1096 | ||
1097 | my $cts = eval { PVE::API2::LXC->vmlist({ node => $nodename }) }; | |
1098 | if ($@) { | |
1099 | log_warn("Failed to retrieve information about this node's CTs - $@"); | |
1100 | return; | |
1101 | } | |
1102 | ||
1103 | if (!defined($cts) || !scalar(@$cts)) { | |
1104 | log_skip("No containers on node detected."); | |
1105 | return; | |
1106 | } | |
1107 | ||
1108 | my @running_cts = sort { $a <=> $b } grep { $_->{status} eq 'running' } @$cts; | |
1109 | my @offline_cts = sort { $a <=> $b } grep { $_->{status} ne 'running' } @$cts; | |
1110 | ||
1111 | for my $ct (@running_cts) { | |
1112 | my $ctid = $ct->{vmid}; | |
1113 | my $pid = eval { PVE::LXC::find_lxc_pid($ctid) }; | |
1114 | if (my $err = $@) { | |
1115 | log_warn("Failed to get PID for running CT $ctid - $err"); | |
1116 | next; | |
1117 | } | |
1118 | my $rootdir = "/proc/$pid/root"; | |
1119 | my $conf = PVE::LXC::Config->load_config($ctid); | |
1120 | ||
1121 | my $ret = eval { $supports_cgroupv2->($conf, $rootdir, $ctid) }; | |
1122 | if (my $err = $@) { | |
1123 | log_warn("Failed to get cgroup support status for CT $ctid - $err"); | |
1124 | next; | |
1125 | } | |
1126 | if (!$ret) { | |
1127 | $log_problem->($ctid); | |
1128 | return; | |
1129 | } | |
1130 | } | |
1131 | ||
1132 | my $storage_cfg = PVE::Storage::config(); | |
1133 | for my $ct (@offline_cts) { | |
1134 | my $ctid = $ct->{vmid}; | |
1135 | my ($conf, $rootdir, $ret); | |
1136 | eval { | |
1137 | $conf = PVE::LXC::Config->load_config($ctid); | |
1138 | $rootdir = PVE::LXC::mount_all($ctid, $storage_cfg, $conf); | |
1139 | $ret = $supports_cgroupv2->($conf, $rootdir, $ctid); | |
1140 | }; | |
1141 | if (my $err = $@) { | |
1142 | log_warn("Failed to load config and mount CT $ctid - $err"); | |
1143 | eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) }; | |
1144 | next; | |
1145 | } | |
1146 | if (!$ret) { | |
1147 | $log_problem->($ctid); | |
1148 | eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) }; | |
1149 | last; | |
1150 | } | |
1151 | ||
1152 | eval { PVE::LXC::umount_all($ctid, $storage_cfg, $conf) }; | |
1153 | } | |
1154 | }; | |
1155 | ||
eed1e93e TL |
1156 | sub check_lxcfs_fuse_version { |
1157 | log_info("Checking if LXCFS is running with FUSE3 library, if already upgraded.."); | |
1158 | if (!$upgraded) { | |
1159 | log_skip("not yet upgraded, no need to check the FUSE library version LXCFS uses"); | |
1160 | return; | |
1161 | } | |
1162 | ||
1163 | my $lxcfs_pid = eval { file_get_contents('/run/lxcfs.pid') }; | |
1164 | if (my $err = $@) { | |
1165 | log_fail("failed to get LXCFS pid - $err"); | |
1166 | return; | |
1167 | } | |
1168 | chomp $lxcfs_pid; | |
1169 | ||
1170 | my $lxcfs_maps = eval { file_get_contents("/proc/${lxcfs_pid}/maps") }; | |
1171 | if (my $err = $@) { | |
1172 | log_fail("failed to get LXCFS maps - $err"); | |
1173 | return; | |
1174 | } | |
1175 | ||
1176 | if ($lxcfs_maps =~ /\/libfuse.so.2/s) { | |
1177 | log_warn("systems seems to be upgraded but LXCFS is still running with FUSE 2 library, not yet rebooted?") | |
1178 | } elsif ($lxcfs_maps =~ /\/libfuse3.so.3/s) { | |
1179 | log_pass("systems seems to be upgraded and LXCFS is running with FUSE 3 library") | |
1180 | } | |
1181 | return; | |
1182 | } | |
1183 | ||
a98193c2 TL |
1184 | sub check_apt_repos { |
1185 | log_info("Checking if the suite for the Debian security repository is correct.."); | |
1186 | ||
1187 | my $found = 0; | |
1188 | ||
1189 | my $dir = '/etc/apt/sources.list.d'; | |
1190 | my $in_dir = 0; | |
1191 | ||
1192 | # TODO: check that (original) debian and Proxmox VE mirrors are present. | |
1193 | ||
114e5f2c TL |
1194 | my ($found_suite, $found_suite_where); |
1195 | my ($mismatches, $strange_suites); | |
1196 | ||
a98193c2 TL |
1197 | my $check_file = sub { |
1198 | my ($file) = @_; | |
1199 | ||
1200 | $file = "${dir}/${file}" if $in_dir; | |
1201 | ||
1202 | my $raw = eval { PVE::Tools::file_get_contents($file) }; | |
1203 | return if !defined($raw); | |
1204 | my @lines = split(/\n/, $raw); | |
1205 | ||
1206 | my $number = 0; | |
1207 | for my $line (@lines) { | |
1208 | $number++; | |
1209 | ||
1210 | next if length($line) == 0; # split would result in undef then... | |
1211 | ||
1212 | ($line) = split(/#/, $line); | |
1213 | ||
1214 | next if $line !~ m/^deb[[:space:]]/; # is case sensitive | |
1215 | ||
1216 | my $suite; | |
114e5f2c | 1217 | if ($line =~ m|deb\s+\w+://\S+\s+(\S*)|i) { |
a98193c2 TL |
1218 | $suite = $1; |
1219 | } else { | |
1220 | next; | |
1221 | } | |
114e5f2c | 1222 | my $where = "in ${file}:${number}"; |
a98193c2 | 1223 | |
114e5f2c TL |
1224 | $suite =~ s/-(?:(?:proposed-)?updates|backports|debug|security)(?:-debug)?$//; |
1225 | if ($suite ne $old_suite && $suite ne $new_suite && !$older_suites->{$suite}) { | |
1226 | push $strange_suites->@*, { suite => $suite, where => $where }; | |
1227 | next; | |
1228 | } | |
a98193c2 | 1229 | |
114e5f2c TL |
1230 | if (!defined($found_suite)) { |
1231 | $found_suite = $suite; | |
1232 | $found_suite_where = $where; | |
1233 | } elsif ($suite ne $found_suite) { | |
1234 | if (!defined($mismatches)) { | |
1235 | $mismatches = []; | |
1236 | push $mismatches->@*, | |
1237 | { suite => $found_suite, where => $found_suite_where}, | |
1238 | { suite => $suite, where => $where}; | |
1239 | } else { | |
1240 | push $mismatches->@*, { suite => $suite, where => $where}; | |
1241 | } | |
1242 | } | |
a98193c2 TL |
1243 | } |
1244 | }; | |
1245 | ||
1246 | $check_file->("/etc/apt/sources.list"); | |
1247 | ||
1248 | $in_dir = 1; | |
1249 | ||
1250 | PVE::Tools::dir_glob_foreach($dir, '^.*\.list$', $check_file); | |
1251 | ||
114e5f2c TL |
1252 | if ($strange_suites) { |
1253 | my @strange_list = map { "found suite $_->{suite} at $_->{where}" } $strange_suites->@*; | |
1254 | log_notice( | |
1255 | "found unusual suites that are neither old '$old_suite' nor new '$new_suite':" | |
1256 | ."\n " . join("\n ", @strange_list) | |
1257 | ."\n Please ensure these repositories are shipping compatible packages for the upgrade!" | |
1258 | ); | |
1259 | } | |
1260 | if (defined($mismatches)) { | |
1261 | my @mismatch_list = map { "found suite $_->{suite} at $_->{where}" } $mismatches->@*; | |
1262 | ||
1263 | log_fail( | |
1264 | "Found mixed old and new package repository suites, fix before upgrading! Mismatches:" | |
1265 | ."\n " . join("\n ", @mismatch_list) | |
1266 | ."\n Configure the same base-suite for all Proxmox and Debian provided repos and ask" | |
1267 | ." original vendor for any third-party repos." | |
1268 | ."\n E.g., for the upgrade to Proxmox VE ".($min_pve_major + 1)." use the '$new_suite' suite." | |
1269 | ); | |
1270 | } elsif (defined($strange_suites)) { | |
1271 | log_notice("found no suite mismatches, but found at least one strange suite"); | |
1272 | } else { | |
1273 | log_pass("found no suite mismatch"); | |
a98193c2 TL |
1274 | } |
1275 | } | |
1276 | ||
ffa79167 TL |
1277 | sub check_nvidia_vgpu_service { |
1278 | log_info("Checking for existence of NVIDIA vGPU Manager.."); | |
1279 | ||
1280 | my $msg = "NVIDIA vGPU Service found, possibly not compatible with newer kernel versions, check" | |
1281 | ." with their documentation and https://pve.proxmox.com/wiki/Upgrade_from_7_to_8#Known_upgrade_issues."; | |
1282 | ||
1283 | my $state = $get_systemd_unit_state->("nvidia-vgpu-mgr.service", 1); | |
1284 | if ($state && $state eq 'active') { | |
1285 | log_warn("Running $msg"); | |
1286 | } elsif ($state && $state ne 'unknown') { | |
1287 | log_warn($msg); | |
1288 | } else { | |
1289 | log_pass("No NVIDIA vGPU Service found."); | |
1290 | } | |
1291 | } | |
1292 | ||
a98193c2 TL |
1293 | sub check_time_sync { |
1294 | my $unit_active = sub { return $get_systemd_unit_state->($_[0], 1) eq 'active' ? $_[0] : undef }; | |
1295 | ||
1296 | log_info("Checking for supported & active NTP service.."); | |
1297 | if ($unit_active->('systemd-timesyncd.service')) { | |
1298 | log_warn( | |
1299 | "systemd-timesyncd is not the best choice for time-keeping on servers, due to only applying" | |
eed1e93e | 1300 | ." updates on boot.\n While not necessary for the upgrade it's recommended to use one of:\n" |
a98193c2 TL |
1301 | ." * chrony (Default in new Proxmox VE installations)\n * ntpsec\n * openntpd\n" |
1302 | ); | |
1303 | } elsif ($unit_active->('ntp.service')) { | |
1304 | log_info("Debian deprecated and removed the ntp package for Bookworm, but the system" | |
1305 | ." will automatically migrate to the 'ntpsec' replacement package on upgrade."); | |
1306 | } elsif (my $active_ntp = ($unit_active->('chrony.service') || $unit_active->('openntpd.service') || $unit_active->('ntpsec.service'))) { | |
1307 | log_pass("Detected active time synchronisation unit '$active_ntp'"); | |
1308 | } else { | |
1309 | log_warn( | |
1310 | "No (active) time synchronisation daemon (NTP) detected, but synchronized systems are important," | |
1311 | ." especially for cluster and/or ceph!" | |
1312 | ); | |
1313 | } | |
1314 | } | |
1315 | ||
35069cdb SI |
1316 | sub check_bootloader { |
1317 | log_info("Checking bootloader configuration..."); | |
35069cdb | 1318 | |
67c655b9 SI |
1319 | if (! -d '/sys/firmware/efi') { |
1320 | log_skip("System booted in legacy-mode - no need for additional packages"); | |
35069cdb SI |
1321 | return; |
1322 | } | |
1323 | ||
67c655b9 SI |
1324 | if ( -f "/etc/kernel/proxmox-boot-uuids") { |
1325 | if (!$upgraded) { | |
1326 | log_skip("not yet upgraded, no need to check the presence of systemd-boot"); | |
1327 | return; | |
1328 | } | |
1329 | if ( -f "/usr/share/doc/systemd-boot/changelog.Debian.gz") { | |
1330 | log_pass("bootloader packages installed correctly"); | |
1331 | return; | |
1332 | } | |
35069cdb SI |
1333 | log_warn( |
1334 | "proxmox-boot-tool is used for bootloader configuration in uefi mode" | |
67c655b9 SI |
1335 | . " but the separate systemd-boot package is not installed," |
1336 | . " initializing new ESPs will not work until the package is installed" | |
1337 | ); | |
1338 | return; | |
1339 | } elsif ( ! -f "/usr/share/doc/grub-efi-amd64/changelog.Debian.gz" ) { | |
1340 | log_warn( | |
1341 | "System booted in uefi mode but grub-efi-amd64 meta-package not installed," | |
1342 | . " new grub versions will not be installed to /boot/efi!" | |
1343 | . " Install grub-efi-amd64." | |
35069cdb | 1344 | ); |
67c655b9 SI |
1345 | return; |
1346 | } else { | |
1347 | log_pass("bootloader packages installed correctly"); | |
35069cdb SI |
1348 | } |
1349 | } | |
1350 | ||
0329876c CE |
1351 | sub check_dkms_modules { |
1352 | log_info("Check for dkms modules..."); | |
1353 | ||
1354 | my $count; | |
1355 | my $set_count = sub { | |
1356 | $count = scalar @_; | |
1357 | }; | |
1358 | ||
1359 | my $exit_code = eval { | |
1360 | run_command(['dkms', 'status', '-k', '`uname -r`'], outfunc => $set_count, noerr => 1) | |
1361 | }; | |
1362 | ||
1363 | if ($exit_code != 0) { | |
1364 | log_skip("could not get dkms status"); | |
1365 | } elsif (!$count) { | |
1366 | log_pass("no dkms modules found"); | |
1367 | } else { | |
1368 | log_warn("dkms modules found, this might cause issues during upgrade."); | |
1369 | } | |
1370 | } | |
1371 | ||
a98193c2 TL |
1372 | sub check_misc { |
1373 | print_header("MISCELLANEOUS CHECKS"); | |
1374 | my $ssh_config = eval { PVE::Tools::file_get_contents('/root/.ssh/config') }; | |
1375 | if (defined($ssh_config)) { | |
1376 | log_fail("Unsupported SSH Cipher configured for root in /root/.ssh/config: $1") | |
1377 | if $ssh_config =~ /^Ciphers .*(blowfish|arcfour|3des).*$/m; | |
1378 | } else { | |
1379 | log_skip("No SSH config file found."); | |
1380 | } | |
1381 | ||
1382 | log_info("Checking common daemon services.."); | |
1383 | $log_systemd_unit_state->('pveproxy.service'); | |
1384 | $log_systemd_unit_state->('pvedaemon.service'); | |
1385 | $log_systemd_unit_state->('pvescheduler.service'); | |
1386 | $log_systemd_unit_state->('pvestatd.service'); | |
1387 | ||
1388 | check_time_sync(); | |
1389 | ||
1390 | my $root_free = PVE::Tools::df('/', 10); | |
1391 | log_warn("Less than 5 GB free space on root file system.") | |
1392 | if defined($root_free) && $root_free->{avail} < 5 * 1000*1000*1000; | |
1393 | ||
1394 | log_info("Checking for running guests.."); | |
1395 | my $running_guests = 0; | |
1396 | ||
1397 | my $vms = eval { PVE::API2::Qemu->vmlist({ node => $nodename }) }; | |
1398 | log_warn("Failed to retrieve information about this node's VMs - $@") if $@; | |
1399 | $running_guests += grep { $_->{status} eq 'running' } @$vms if defined($vms); | |
1400 | ||
1401 | my $cts = eval { PVE::API2::LXC->vmlist({ node => $nodename }) }; | |
1402 | log_warn("Failed to retrieve information about this node's CTs - $@") if $@; | |
1403 | $running_guests += grep { $_->{status} eq 'running' } @$cts if defined($cts); | |
1404 | ||
1405 | if ($running_guests > 0) { | |
1406 | log_warn("$running_guests running guest(s) detected - consider migrating or stopping them.") | |
1407 | } else { | |
1408 | log_pass("no running guest detected.") | |
1409 | } | |
1410 | ||
1411 | log_info("Checking if the local node's hostname '$nodename' is resolvable.."); | |
1412 | my $local_ip = eval { PVE::Network::get_ip_from_hostname($nodename) }; | |
1413 | if ($@) { | |
1414 | log_warn("Failed to resolve hostname '$nodename' to IP - $@"); | |
1415 | } else { | |
1416 | log_info("Checking if resolved IP is configured on local node.."); | |
1417 | my $cidr = Net::IP::ip_is_ipv6($local_ip) ? "$local_ip/128" : "$local_ip/32"; | |
1418 | my $configured_ips = PVE::Network::get_local_ip_from_cidr($cidr); | |
1419 | my $ip_count = scalar(@$configured_ips); | |
1420 | ||
1421 | if ($ip_count <= 0) { | |
1422 | log_fail("Resolved node IP '$local_ip' not configured or active for '$nodename'"); | |
1423 | } elsif ($ip_count > 1) { | |
1424 | log_warn("Resolved node IP '$local_ip' active on multiple ($ip_count) interfaces!"); | |
1425 | } else { | |
1426 | log_pass("Resolved node IP '$local_ip' configured and active on single interface."); | |
1427 | } | |
1428 | } | |
1429 | ||
1430 | log_info("Check node certificate's RSA key size"); | |
1431 | my $certs = PVE::API2::Certificates->info({ node => $nodename }); | |
1432 | my $certs_check = { | |
1433 | 'rsaEncryption' => { | |
1434 | minsize => 2048, | |
1435 | name => 'RSA', | |
1436 | }, | |
1437 | 'id-ecPublicKey' => { | |
1438 | minsize => 224, | |
1439 | name => 'ECC', | |
1440 | }, | |
1441 | }; | |
1442 | ||
1443 | my $certs_check_failed = 0; | |
ffa79167 | 1444 | for my $cert (@$certs) { |
a98193c2 TL |
1445 | my ($type, $size, $fn) = $cert->@{qw(public-key-type public-key-bits filename)}; |
1446 | ||
1447 | if (!defined($type) || !defined($size)) { | |
1448 | log_warn("'$fn': cannot check certificate, failed to get it's type or size!"); | |
1449 | } | |
1450 | ||
1451 | my $check = $certs_check->{$type}; | |
1452 | if (!defined($check)) { | |
1453 | log_warn("'$fn': certificate's public key type '$type' unknown!"); | |
1454 | next; | |
1455 | } | |
1456 | ||
1457 | if ($size < $check->{minsize}) { | |
1458 | log_fail("'$fn', certificate's $check->{name} public key size is less than 2048 bit"); | |
1459 | $certs_check_failed = 1; | |
1460 | } else { | |
1461 | log_pass("Certificate '$fn' passed Debian Busters (and newer) security level for TLS connections ($size >= 2048)"); | |
1462 | } | |
1463 | } | |
1464 | ||
1465 | check_backup_retention_settings(); | |
1466 | check_cifs_credential_location(); | |
1467 | check_custom_pool_roles(); | |
eed1e93e | 1468 | check_lxcfs_fuse_version(); |
a98193c2 TL |
1469 | check_node_and_guest_configurations(); |
1470 | check_apt_repos(); | |
ffa79167 | 1471 | check_nvidia_vgpu_service(); |
35069cdb | 1472 | check_bootloader(); |
0329876c | 1473 | check_dkms_modules(); |
a98193c2 TL |
1474 | } |
1475 | ||
1476 | my sub colored_if { | |
1477 | my ($str, $color, $condition) = @_; | |
1478 | return "". ($condition ? colored($str, $color) : $str); | |
1479 | } | |
1480 | ||
1481 | __PACKAGE__->register_method ({ | |
1482 | name => 'checklist', | |
1483 | path => 'checklist', | |
1484 | method => 'GET', | |
1485 | description => 'Check (pre-/post-)upgrade conditions.', | |
1486 | parameters => { | |
1487 | additionalProperties => 0, | |
1488 | properties => { | |
1489 | full => { | |
1490 | description => 'perform additional, expensive checks.', | |
1491 | type => 'boolean', | |
1492 | optional => 1, | |
1493 | default => 0, | |
1494 | }, | |
1495 | }, | |
1496 | }, | |
1497 | returns => { type => 'null' }, | |
1498 | code => sub { | |
1499 | my ($param) = @_; | |
1500 | ||
1501 | my $kernel_cli = PVE::Tools::file_get_contents('/proc/cmdline'); | |
1502 | if ($kernel_cli =~ /systemd.unified_cgroup_hierarchy=0/){ | |
1503 | $forced_legacy_cgroup = 1; | |
1504 | } | |
1505 | ||
1506 | check_pve_packages(); | |
1507 | check_cluster_corosync(); | |
1508 | check_ceph(); | |
1509 | check_storage_health(); | |
1510 | check_misc(); | |
1511 | ||
1512 | if ($param->{full}) { | |
1513 | check_containers_cgroup_compat(); | |
1514 | } else { | |
1515 | log_skip("NOTE: Expensive checks, like CT cgroupv2 compat, not performed without '--full' parameter"); | |
1516 | } | |
1517 | ||
1518 | print_header("SUMMARY"); | |
1519 | ||
1520 | my $total = 0; | |
1521 | $total += $_ for values %$counters; | |
1522 | ||
1523 | print "TOTAL: $total\n"; | |
1524 | print colored("PASSED: $counters->{pass}\n", 'green'); | |
1525 | print "SKIPPED: $counters->{skip}\n"; | |
1526 | print colored_if("WARNINGS: $counters->{warn}\n", 'yellow', $counters->{warn} > 0); | |
1527 | print colored_if("FAILURES: $counters->{fail}\n", 'bold red', $counters->{fail} > 0); | |
1528 | ||
1529 | if ($counters->{warn} > 0 || $counters->{fail} > 0) { | |
1530 | my $color = $counters->{fail} > 0 ? 'bold red' : 'yellow'; | |
1531 | print colored("\nATTENTION: Please check the output for detailed information!\n", $color); | |
1532 | print colored("Try to solve the problems one at a time and then run this checklist tool again.\n", $color) if $counters->{fail} > 0; | |
1533 | } | |
1534 | ||
1535 | return undef; | |
1536 | }}); | |
1537 | ||
1538 | our $cmddef = [ __PACKAGE__, 'checklist', [], {}]; | |
1539 | ||
1540 | 1; |