[pve-devel] [PATCH manager v2] Make PVE6 compatible with supported ceph versions
Alwin Antreich
a.antreich at proxmox.com
Wed Jun 3 13:39:42 CEST 2020
Luminous, Nautilus and Octopus. In Octopus the mon_status was dropped.
Also the ceph status was cleaned up and doesn't provide the mgrmap and
monmap.
The rados queries used in the ceph status API endpoints (cluster / node)
were factored out and merged to one place.
Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
v1 -> v2: make mon/mgr dump optional for Ceph versions prior Octopus
PVE/API2/Ceph.pm | 5 +----
PVE/API2/Ceph/MON.pm | 6 +++---
PVE/API2/Ceph/OSD.pm | 2 +-
PVE/API2/Cluster/Ceph.pm | 5 +----
PVE/Ceph/Tools.pm | 17 +++++++++++++++++
www/manager6/ceph/StatusDetail.js | 12 ++++++++----
6 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 85a04101..afc1bdbd 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -580,10 +580,7 @@ __PACKAGE__->register_method ({
PVE::Ceph::Tools::check_ceph_inited();
- my $rados = PVE::RADOS->new();
- my $status = $rados->mon_command({ prefix => 'status' });
- $status->{health} = $rados->mon_command({ prefix => 'health', detail => 'detail' });
- return $status;
+ return PVE::Ceph::Tools::ceph_cluster_status();
}});
__PACKAGE__->register_method ({
diff --git a/PVE/API2/Ceph/MON.pm b/PVE/API2/Ceph/MON.pm
index 3baeac52..b33b8700 100644
--- a/PVE/API2/Ceph/MON.pm
+++ b/PVE/API2/Ceph/MON.pm
@@ -130,7 +130,7 @@ __PACKAGE__->register_method ({
my $monhash = PVE::Ceph::Services::get_services_info("mon", $cfg, $rados);
if ($rados) {
- my $monstat = $rados->mon_command({ prefix => 'mon_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
my $mons = $monstat->{monmap}->{mons};
foreach my $d (@$mons) {
@@ -338,7 +338,7 @@ __PACKAGE__->register_method ({
my $monsection = "mon.$monid";
my $rados = PVE::RADOS->new();
- my $monstat = $rados->mon_command({ prefix => 'mon_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
my $monlist = $monstat->{monmap}->{mons};
my $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, $rados);
@@ -356,7 +356,7 @@ __PACKAGE__->register_method ({
# reopen with longer timeout
$rados = PVE::RADOS->new(timeout => PVE::Ceph::Tools::get_config('long_rados_timeout'));
$monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, $rados);
- $monstat = $rados->mon_command({ prefix => 'mon_status' });
+ $monstat = $rados->mon_command({ prefix => 'quorum_status' });
$monlist = $monstat->{monmap}->{mons};
my $addr;
diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
index a514c502..ceaed129 100644
--- a/PVE/API2/Ceph/OSD.pm
+++ b/PVE/API2/Ceph/OSD.pm
@@ -344,7 +344,7 @@ __PACKAGE__->register_method ({
# get necessary ceph infos
my $rados = PVE::RADOS->new();
- my $monstat = $rados->mon_command({ prefix => 'mon_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
die "unable to get fsid\n" if !$monstat->{monmap} || !$monstat->{monmap}->{fsid};
my $fsid = $monstat->{monmap}->{fsid};
diff --git a/PVE/API2/Cluster/Ceph.pm b/PVE/API2/Cluster/Ceph.pm
index e18d421e..c0277221 100644
--- a/PVE/API2/Cluster/Ceph.pm
+++ b/PVE/API2/Cluster/Ceph.pm
@@ -142,10 +142,7 @@ __PACKAGE__->register_method ({
PVE::Ceph::Tools::check_ceph_inited();
- my $rados = PVE::RADOS->new();
- my $status = $rados->mon_command({ prefix => 'status' });
- $status->{health} = $rados->mon_command({ prefix => 'health', detail => 'detail' });
- return $status;
+ return PVE::Ceph::Tools::ceph_cluster_status();
}
});
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 3273c7d1..a73b791b 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -468,4 +468,21 @@ sub get_real_flag_name {
return $flagmap->{$flag} // $flag;
}
+sub ceph_cluster_status {
+ my ($rados) = @_;
+ $rados = PVE::RADOS->new() if !$rados;
+
+ my $ceph_version = get_local_version(1);
+ my $status = $rados->mon_command({ prefix => 'status' });
+
+ $status->{health} = $rados->mon_command({ prefix => 'health', detail => 'detail' });
+
+ if (!$ceph_version < 15) {
+ $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' });
+ $status->{mgrmap} = $rados->mon_command({ prefix => 'mgr dump' });
+ }
+
+ return $status;
+}
+
1;
diff --git a/www/manager6/ceph/StatusDetail.js b/www/manager6/ceph/StatusDetail.js
index 8185e3bb..211b0d6f 100644
--- a/www/manager6/ceph/StatusDetail.js
+++ b/www/manager6/ceph/StatusDetail.js
@@ -214,8 +214,11 @@ Ext.define('PVE.ceph.StatusDetail', {
var pgmap = status.pgmap || {};
var health = status.health || {};
- var osdmap = status.osdmap || { osdmap: {} };
+ var osdmap = status.osdmap || {};
+ if (typeof osdmap.osdmap != "undefined") {
+ osdmap = osdmap.osdmap;
+ }
// update pgs sorted
var pgs_by_state = pgmap.pgs_by_state || [];
@@ -263,9 +266,10 @@ Ext.define('PVE.ceph.StatusDetail', {
// update osds counts
- var total_osds = osdmap.osdmap.num_osds || 0;
- var in_osds = osdmap.osdmap.num_in_osds || 0;
- var up_osds = osdmap.osdmap.num_up_osds || 0;
+ // pre-octopus || octopus || 0
+ var total_osds = osdmap.num_osds || 0;
+ var in_osds = osdmap.num_in_osds || 0;
+ var up_osds = osdmap.num_up_osds || 0;
var out_osds = total_osds - in_osds;
var down_osds = total_osds - up_osds;
--
2.26.2
More information about the pve-devel
mailing list