[pve-devel] [PATCH manager 1/2] Make PVE6 compatible with supported ceph versions
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jun 2 14:08:00 CEST 2020
On 5/28/20 4:41 PM, Alwin Antreich wrote:
> 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>
> ---
> note: as discussed off-list with Dominik, the status API call could also
> be split into multiple API calls. To provide mgrmap, monmap and
> status separately.
>
> 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 | 13 +++++++++++++
> www/manager6/ceph/StatusDetail.js | 7 ++++---
> 6 files changed, 23 insertions(+), 15 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..b4a83f2e 100644
> --- a/PVE/Ceph/Tools.pm
> +++ b/PVE/Ceph/Tools.pm
> @@ -468,4 +468,17 @@ sub get_real_flag_name {
> return $flagmap->{$flag} // $flag;
> }
>
> +sub ceph_cluster_status {
> + my ($rados) = @_;
> + $rados = PVE::RADOS->new() if !$rados;
> +
> + my $status = $rados->mon_command({ prefix => 'status' });
> +
> + $status->{health} = $rados->mon_command({ prefix => 'health', detail => 'detail' });
> + $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' });
Guarding this could be one way but at least doing it only if $status->{xy} isn't
already defined would avoid (useless?) extra calls in the nautilus case?
> + $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..6561eba3 100644
> --- a/www/manager6/ceph/StatusDetail.js
> +++ b/www/manager6/ceph/StatusDetail.js
> @@ -263,9 +263,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.osdmap.num_osds || osdmap.num_osds || 0;
> + var in_osds = osdmap.osdmap.num_in_osds || osdmap.num_in_osds || 0;
> + var up_osds = osdmap.osdmap.num_up_osds || osdmap.num_up_osds || 0;
> var out_osds = total_osds - in_osds;
> var down_osds = total_osds - up_osds;
>
>
More information about the pve-devel
mailing list