public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH] pve7to8: ceph version check: ignore commit hash
Date: Fri,  2 Jun 2023 18:04:02 +0200	[thread overview]
Message-ID: <20230602160402.164448-1-a.lauterer@proxmox.com> (raw)

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@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





             reply	other threads:[~2023-06-02 16:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 16:04 Aaron Lauterer [this message]
2023-06-05 17:21 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230602160402.164448-1-a.lauterer@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal