[pve-devel] [PATCH] pve7to8: ceph version check: ignore commit hash

Aaron Lauterer a.lauterer at proxmox.com
Fri Jun 2 18:04:02 CEST 2023


The commit hash of the Ceph version might be different between major
releases. For example:
ceph version 17.2.6 (810db68029296377607028a6c6da1ec06f5a2b27) quincy (stable)
ceph version 17.2.6 (995dec2cdae920da21db2d455e55efbc339bde24) quincy (stable)

This can lead to unnecessary warnings of multiple detected versions.
Therefore, extract the version, e.g. 'ceph version 17.2.6', and the
commit hash. Use the simplified version for the version checks and show
an info line when the commit is different instead of a warning.
If the commit hashes are the only difference, we are likely in the
middle of the upgrade.

Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
 PVE/CLI/pve7to8.pm | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/PVE/CLI/pve7to8.pm b/PVE/CLI/pve7to8.pm
index 06f4e2bb..cc2bd643 100644
--- a/PVE/CLI/pve7to8.pm
+++ b/PVE/CLI/pve7to8.pm
@@ -500,9 +500,24 @@ sub check_ceph {
 	    { 'key' => 'osd', 'name' => 'OSD' },
 	];
 
+	my $ceph_versions_simple = {};
+	my $ceph_versions_commits = {};
+	for my $type (keys %$ceph_versions) {
+	    for my $full_version (keys $ceph_versions->{$type}->%*) {
+		if ($full_version =~ m/^(.*) \((.*)\).*\(.*\)$/) {
+		    # String is in the form of
+		    # ceph version 17.2.6 (810db68029296377607028a6c6da1ec06f5a2b27) quincy (stable)
+		    # only check the first part, e.g. 'ceph version 17.2.6', the commit hash can
+		    # be different
+		    $ceph_versions_simple->{$type}->{$1} = 1;
+		    $ceph_versions_commits->{$type}->{$2} = 1;
+		}
+	    }
+	}
+
 	foreach my $service (@$services) {
 	    my ($name, $key) = $service->@{'name', 'key'};
-	    if (my $service_versions = $ceph_versions->{$key}) {
+	    if (my $service_versions = $ceph_versions_simple->{$key}) {
 		if (keys %$service_versions == 0) {
 		    log_skip("no running instances detected for daemon type $name.");
 		} elsif (keys %$service_versions == 1) {
@@ -513,6 +528,12 @@ sub check_ceph {
 	    } else {
 		log_skip("unable to determine versions of running Ceph $name instances.");
 	    }
+	    if (my $service_commits = $ceph_versions_commits->{$key}) {
+		if (keys %$service_commits > 1) {
+		    log_info("multiple version commits detected for daemon type $name. ".
+			"Are you in the middle of the upgrade?");
+		}
+	    }
 	}
 
 	my $overall_versions = $ceph_versions->{overall};
@@ -521,7 +542,7 @@ sub check_ceph {
 	} elsif (keys %$overall_versions == 1) {
 	    log_pass("single running overall version detected for all Ceph daemon types.");
 	    $noout_wanted = 0; # off post-upgrade, on pre-upgrade
-	} else {
+	} elsif (keys $ceph_versions_simple->{overall}->%* != 1) {
 	    log_warn("overall version mismatch detected, check 'ceph versions' output for details!");
 	}
     }
-- 
2.30.2






More information about the pve-devel mailing list