]> git.proxmox.com Git - pve-manager.git/commitdiff
Make PVE6 compatible with supported ceph versions
authorAlwin Antreich <a.antreich@proxmox.com>
Wed, 3 Jun 2020 11:39:42 +0000 (13:39 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 3 Jun 2020 12:23:38 +0000 (14:23 +0200)
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@proxmox.com>
PVE/API2/Ceph.pm
PVE/API2/Ceph/MON.pm
PVE/API2/Ceph/OSD.pm
PVE/API2/Cluster/Ceph.pm
PVE/Ceph/Tools.pm
www/manager6/ceph/StatusDetail.js

index 85a04101be04bd2baebce28ccc4e8230ef188693..afc1bdbd5912214f1ce2b8825e9e6b8a8f16be54 100644 (file)
@@ -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 ({
index 3baeac525336a151282b25e689aa267dbb0fc0c4..b33b8700da49fa1885c2e19438857989ce926d0e 100644 (file)
@@ -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;
index a514c502492355565700ca3d1c7ea4950cf3fa50..ceaed129bf558e7c88245a1a18faa0c1cae93263 100644 (file)
@@ -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};
index e18d421e72566db92959fef53b1fc973f5a42c11..c0277221e57e8988b8cc2ab9d3fe1070fd52b546 100644 (file)
@@ -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();
     }
 });
 
index 3273c7d1ab8fb9bb52a866e11173f3190b4fe4b6..a73b791b121b2e3d5303a02d756d3521cad3e4bc 100644 (file)
@@ -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;
index 8185e3bbd6bb0773da5ac55d2eec05dd6db8c82f..211b0d6fb45079cdde73094a64fe721f92714c02 100644 (file)
@@ -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;