]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/CLI/pve7to8.pm
pve7to8: suggest removing outdated kernel meta packages after upgrade+reboot
[pve-manager.git] / PVE / CLI / pve7to8.pm
index 9bde4b74457fe1168c6324be71781f6bd9c2bc76..9dc3be9771ad7dafb8d9e40ec3e84589a36617bc 100644 (file)
@@ -92,17 +92,21 @@ sub print_header {
 }
 
 my $get_systemd_unit_state = sub {
-    my ($unit) = @_;
+    my ($unit, $surpress_stderr) = @_;
 
     my $state;
     my $filter_output = sub {
        $state = shift;
        chomp $state;
     };
+
+    my %extra = (outfunc => $filter_output, noerr => 1);
+    $extra{errfunc} = sub {  } if $surpress_stderr;
+
     eval {
-       run_command(['systemctl', 'is-enabled', "$unit"], outfunc => $filter_output, noerr => 1);
+       run_command(['systemctl', 'is-enabled', "$unit"], %extra);
        return if !defined($state);
-       run_command(['systemctl', 'is-active', "$unit"], outfunc => $filter_output, noerr => 1);
+       run_command(['systemctl', 'is-active', "$unit"], %extra);
     };
 
     return $state // 'unknown';
@@ -189,12 +193,34 @@ sub check_pve_packages {
        if (!defined($kernel_ver)) {
            log_fail("unable to determine running kernel version.");
        } elsif ($kernel_ver =~ /^$krunning/) {
-           log_pass("running kernel '$kernel_ver' is considered suitable for upgrade.");
+           if ($upgraded) {
+               log_pass("running new kernel '$kernel_ver' after upgrade.");
+           } else {
+               log_pass("running kernel '$kernel_ver' is considered suitable for upgrade.");
+           }
        } elsif ($get_pkg->($kinstalled)) {
-           log_warn("expected kernel '$kinstalled' intalled but not yet rebooted!");
+           # with 6.2 kernel being available in both we might want to fine-tune the check?
+           log_warn("a suitable kernel ($kinstalled) is intalled, but an unsuitable ($kernel_ver) is booted, missing reboot?!");
        } else {
            log_warn("unexpected running and installed kernel '$kernel_ver'.");
        }
+
+       if ($upgraded && $kernel_ver =~ /^$krunning/) {
+           my $outdated_kernel_meta_pkgs = [];
+           for my $kernel_meta_version ('5.4', '5.11', '5.13', '5.15') {
+               my $pkg = "pve-kernel-${kernel_meta_version}";
+               if ($get_pkg->($pkg)) {
+                   push @$outdated_kernel_meta_pkgs, $pkg;
+               }
+           }
+           if (scalar(@$outdated_kernel_meta_pkgs) > 0) {
+               log_info(
+                   "Found outdated kernel meta-packages, taking up extra space on boot partitions.\n"
+                   ."      After a successful upgrade, you can remove them using this command:\n"
+                   ."      apt remove " . join(' ', $outdated_kernel_meta_pkgs->@*)
+               );
+           }
+       }
     } else {
        log_fail("proxmox-ve package not found!");
     }
@@ -1061,6 +1087,29 @@ sub check_apt_repos {
     }
 }
 
+sub check_time_sync {
+    my $unit_active = sub { return $get_systemd_unit_state->($_[0], 1) eq 'active' ? $_[0] : undef };
+
+    log_info("Checking for supported & active NTP service..");
+    if ($unit_active->('systemd-timesyncd.service')) {
+       log_warn(
+           "systemd-timesyncd is not the best choice for time-keeping on servers, due to only applying"
+           ." updates on boot.\n  While not necesarry for the upgrade it's recommended to use one of:\n"
+           ."    * chrony (Default in new Proxmox VE installations)\n    * ntpsec\n    * openntpd\n"
+       );
+    } elsif ($unit_active->('ntp.service')) {
+       log_info("Debian deprecated and removed the ntp package for Bookworm, but the system"
+           ." will automatically migrate to the 'ntpsec' replacement package on upgrade.");
+    } elsif (my $active_ntp = ($unit_active->('chrony.service') || $unit_active->('openntpd.service') || $unit_active->('ntpsec.service'))) {
+       log_pass("Detected active time synchronisation unit '$active_ntp'");
+    } else {
+       log_warn(
+           "No (active) time synchronisation daemon (NTP) detected, but synchronized systems are important,"
+           ." especially for cluster and/or ceph!"
+       );
+    }
+}
+
 sub check_misc {
     print_header("MISCELLANEOUS CHECKS");
     my $ssh_config = eval { PVE::Tools::file_get_contents('/root/.ssh/config') };
@@ -1077,6 +1126,8 @@ sub check_misc {
     $log_systemd_unit_state->('pvescheduler.service');
     $log_systemd_unit_state->('pvestatd.service');
 
+    check_time_sync();
+
     my $root_free = PVE::Tools::df('/', 10);
     log_warn("Less than 5 GB free space on root file system.")
        if defined($root_free) && $root_free->{avail} < 5 * 1000*1000*1000;
@@ -1159,6 +1210,11 @@ sub check_misc {
     check_apt_repos();
 }
 
+my sub colored_if {
+    my ($str, $color, $condition) = @_;
+    return "". ($condition ? colored($str, $color) : $str);
+}
+
 __PACKAGE__->register_method ({
     name => 'checklist',
     path => 'checklist',
@@ -1204,8 +1260,8 @@ __PACKAGE__->register_method ({
        print "TOTAL:    $total\n";
        print colored("PASSED:   $counters->{pass}\n", 'green');
        print "SKIPPED:  $counters->{skip}\n";
-       print colored("WARNINGS: $counters->{warn}\n", 'yellow');
-       print colored("FAILURES: $counters->{fail}\n", 'red');
+       print colored_if("WARNINGS: $counters->{warn}\n", 'yellow', $counters->{warn} > 0);
+       print colored_if("FAILURES: $counters->{fail}\n", 'red', $counters->{fail} > 0);
 
        if ($counters->{warn} > 0 || $counters->{fail} > 0) {
            my $color = $counters->{fail} > 0 ? 'red' : 'yellow';