From: Kefu Chai <k.chai@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager 3/5] ceph: add require_osd_release upgrade check
Date: Tue, 28 Apr 2026 10:45:36 +0800 [thread overview]
Message-ID: <20260428024538.3559017-4-k.chai@proxmox.com> (raw)
In-Reply-To: <20260428024538.3559017-1-k.chai@proxmox.com>
Add a get_osd_dump() helper in PVE::Ceph::Tools that wraps the
'osd dump' mon command, and use it to implement a new advisory check
in PVE::Ceph::UpgradeCheck: require_osd_release.
The check warns if require_osd_release is unset or older than the
currently installed Ceph release on the node, and suggests running
'ceph osd require-osd-release <codename>' once all OSDs are upgraded.
Not setting this flag blocks a number of features that the OSDs would
otherwise support.
See
https://docs.ceph.com/en/latest/rados/operations/require-osd-release/
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
---
PVE/Ceph/Releases.pm | 14 ++++++++++
PVE/Ceph/Tools.pm | 6 +++++
PVE/Ceph/UpgradeCheck.pm | 57 +++++++++++++++++++++++++++++++++++++++-
3 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/PVE/Ceph/Releases.pm b/PVE/Ceph/Releases.pm
index 324fcfaf..7eabda60 100644
--- a/PVE/Ceph/Releases.pm
+++ b/PVE/Ceph/Releases.pm
@@ -131,6 +131,20 @@ sub get_available_ceph_release_codenames($include_unstable_releases = 0) {
my $_default_ceph_release_codename;
+# Return the codename (e.g. 'squid') whose major release matches $major,
+# searching all Ceph releases tracked in this module (i.e., not restricted
+# to releases available on the current PVE version). Returns undef if no
+# release matches. The inverse of looking up the major from
+# get_ceph_release_info($codename).
+sub get_codename_for_major_release($major) {
+ my $releases = get_ceph_release_def();
+ for my $codename (keys $releases->%*) {
+ my ($release_major) = split(/\./, $releases->{$codename}->{release});
+ return $codename if $release_major == $major;
+ }
+ return undef;
+}
+
sub get_default_ceph_release_codename {
if (!defined($_default_ceph_release_codename)) {
my $ceph_releases = get_all_available_ceph_releases();
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index c731ac14..4edc967b 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -112,6 +112,12 @@ sub get_cluster_versions {
return $rados->mon_command({ prefix => $cmd });
}
+sub get_osd_dump {
+ my ($rados) = @_;
+ $rados = PVE::RADOS->new() if !$rados;
+ return $rados->mon_command({ prefix => 'osd dump', format => 'json' });
+}
+
sub get_config {
my $key = shift;
diff --git a/PVE/Ceph/UpgradeCheck.pm b/PVE/Ceph/UpgradeCheck.pm
index 6998caf2..5c454fd1 100644
--- a/PVE/Ceph/UpgradeCheck.pm
+++ b/PVE/Ceph/UpgradeCheck.pm
@@ -13,6 +13,7 @@ use warnings;
use PVE::API2::Ceph;
use PVE::API2::Cluster::Ceph;
+use PVE::Ceph::Releases;
use PVE::Ceph::Tools;
use PVE::Cluster;
@@ -50,7 +51,7 @@ sub run_checks {
my ($health_msgs, $noout) = check_health($nodename);
push @messages, $health_msgs->@*;
- # TODO: check OSD min-required version, if to low it breaks stuff!
+ push @messages, check_require_osd_release($supported_release)->@*;
my ($version_msgs, $noout_wanted) = check_versions($supported_release, $upgraded);
push @messages, $version_msgs->@*;
@@ -339,4 +340,58 @@ sub check_local_version_minimum {
return \@out;
}
+# returns the numeric release value (e.g. 19.2) for a given codename, or undef
+# if the codename is not known to PVE::Ceph::Releases.
+my sub release_number {
+ my ($codename) = @_;
+ return undef if !$codename;
+ my $info = PVE::Ceph::Releases::get_ceph_release_info($codename);
+ return $info ? $info->{release} : undef;
+}
+
+sub check_require_osd_release {
+ my ($supported_release) = @_;
+
+ my @out;
+
+ my $osdmap = eval { PVE::Ceph::Tools::get_osd_dump() };
+ if ($@ || !$osdmap) {
+ my $err = $@ || 'empty osd dump';
+ push @out, { level => 'warn', msg => "could not query osd dump: $err" };
+ return \@out;
+ }
+
+ my $current = $osdmap->{require_osd_release} // '';
+ if (!$current) {
+ push @out,
+ {
+ level => 'warn',
+ msg => "require_osd_release is not set. Run"
+ . " 'ceph osd require-osd-release <codename>' after all OSDs are upgraded to"
+ . " the new release.",
+ };
+ return \@out;
+ }
+
+ my $expected_codename = PVE::Ceph::Releases::get_codename_for_major_release($supported_release)
+ // PVE::Ceph::Releases::get_default_ceph_release_codename();
+ my $expected_release = release_number($expected_codename);
+ my $current_release = release_number($current);
+
+ if (!defined($current_release) || $current_release < $expected_release) {
+ push @out,
+ {
+ level => 'warn',
+ msg => "require_osd_release is '$current', older than '$expected_codename'."
+ . " Once all OSDs are upgraded, run"
+ . " 'ceph osd require-osd-release $expected_codename' to unlock features"
+ . " that depend on the newer release.",
+ };
+ } else {
+ push @out, { level => 'pass', msg => "require_osd_release is at '$current'." };
+ }
+
+ return \@out;
+}
+
1;
--
2.47.3
next prev parent reply other threads:[~2026-04-28 2:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 2:45 [PATCH manager 0/5] ceph: add 'pveceph upgrade-check' subcommand Kefu Chai
2026-04-28 2:45 ` [PATCH manager 1/5] pve8to9: extract ceph checks into PVE::Ceph::UpgradeCheck Kefu Chai
2026-04-28 2:45 ` [PATCH manager 2/5] ceph: add pveceph upgrade-check command Kefu Chai
2026-04-28 2:45 ` Kefu Chai [this message]
2026-04-28 2:45 ` [PATCH manager 4/5] ceph: add require_min_compat_client upgrade check Kefu Chai
2026-04-28 2:45 ` [PATCH manager 5/5] ceph: drop duplicate release-to-codename map in upgrade checks Kefu Chai
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=20260428024538.3559017-4-k.chai@proxmox.com \
--to=k.chai@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