From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 manager 4/7] ceph: adapt to changed rados mon_command return values
Date: Fri, 25 Mar 2022 11:55:07 +0100 [thread overview]
Message-ID: <20220325105510.3262101-5-a.lauterer@proxmox.com> (raw)
In-Reply-To: <20220325105510.3262101-1-a.lauterer@proxmox.com>
The mon_command now returns a hash ref but current calls are only
interested in the 'data'.
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
Needs to be coordinated with librados2-perl changes from patch 1
PVE/API2/Ceph.pm | 6 +++---
PVE/API2/Ceph/MGR.pm | 2 +-
PVE/API2/Ceph/MON.pm | 19 +++++++++++++------
PVE/API2/Ceph/OSD.pm | 14 +++++++-------
PVE/API2/Ceph/Pools.pm | 18 ++++++++++--------
PVE/API2/Cluster/Ceph.pm | 6 +++---
PVE/CLI/pveceph.pm | 4 ++--
PVE/Ceph/Services.pm | 10 +++++-----
PVE/Ceph/Tools.pm | 16 ++++++++--------
9 files changed, 52 insertions(+), 43 deletions(-)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 3bbcfe4c..1e1b1edd 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -168,7 +168,7 @@ __PACKAGE__->register_method ({
PVE::Ceph::Tools::check_ceph_inited();
my $rados = PVE::RADOS->new();
- my $res = $rados->mon_command( { prefix => 'config dump', format => 'json' });
+ my $res = $rados->mon_command( { prefix => 'config dump', format => 'json' })->{data};
foreach my $entry (@$res) {
$entry->{can_update_at_runtime} = $entry->{can_update_at_runtime}? 1 : 0; # JSON::true/false -> 1/0
}
@@ -525,7 +525,7 @@ __PACKAGE__->register_method ({
my $rados = PVE::RADOS->new();
eval {
- my $bindata = $rados->mon_command({ prefix => 'osd getcrushmap', format => 'plain' });
+ my $bindata = $rados->mon_command({ prefix => 'osd getcrushmap', format => 'plain' })->{data};
file_set_contents($mapfile, $bindata);
run_command(['crushtool', '-d', $mapfile, '-o', $mapdata]);
$txt = file_get_contents($mapdata);
@@ -630,7 +630,7 @@ __PACKAGE__->register_method ({
my $rados = PVE::RADOS->new();
- my $rules = $rados->mon_command({ prefix => 'osd crush rule ls' });
+ my $rules = $rados->mon_command({ prefix => 'osd crush rule ls' })->{data};
my $res = [];
diff --git a/PVE/API2/Ceph/MGR.pm b/PVE/API2/Ceph/MGR.pm
index 2dc679ef..5b9087c9 100644
--- a/PVE/API2/Ceph/MGR.pm
+++ b/PVE/API2/Ceph/MGR.pm
@@ -67,7 +67,7 @@ __PACKAGE__->register_method ({
my $mgr_hash = PVE::Ceph::Services::get_services_info("mgr", $cfg, $rados);
- my $mgr_dump = $rados->mon_command({ prefix => 'mgr dump' });
+ my $mgr_dump = $rados->mon_command({ prefix => 'mgr dump' })->{data};
my $active_name = $mgr_dump->{active_name};
$mgr_hash->{$active_name}->{state} = 'active' if $active_name;
diff --git a/PVE/API2/Ceph/MON.pm b/PVE/API2/Ceph/MON.pm
index 12c9caf0..943ba0a0 100644
--- a/PVE/API2/Ceph/MON.pm
+++ b/PVE/API2/Ceph/MON.pm
@@ -28,8 +28,12 @@ my $find_mon_ips = sub {
my $pubnet;
if ($rados) {
- $pubnet = $rados->mon_command({ prefix => "config get" , who => "mon.",
- key => "public_network", format => 'plain' });
+ $pubnet = $rados->mon_command({
+ prefix => "config get",
+ who => "mon.",
+ key => "public_network",
+ format => 'plain',
+ })->{data};
# if not defined in the db, the result is empty, it is also always
# followed by a newline
($pubnet) = $pubnet =~ m/^(\S+)$/;
@@ -231,7 +235,7 @@ __PACKAGE__->register_method ({
my $monhash = PVE::Ceph::Services::get_services_info("mon", $cfg, $rados);
if ($rados) {
- my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' })->{data};
my $mons = $monstat->{monmap}->{mons};
foreach my $d (@$mons) {
@@ -391,7 +395,10 @@ __PACKAGE__->register_method ({
];
if (defined($rados)) { # we can only have a RADOS object if we have a monitor
- my $mapdata = $rados->mon_command({ prefix => 'mon getmap', format => 'plain' });
+ my $mapdata = $rados->mon_command({
+ prefix => 'mon getmap',
+ format => 'plain',
+ })->{data};
file_set_contents($monmap, $mapdata);
run_command($monmaptool_cmd);
} else { # we need to create a monmap for the first monitor
@@ -502,7 +509,7 @@ __PACKAGE__->register_method ({
my $monsection = "mon.$monid";
my $rados = PVE::RADOS->new();
- my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' })->{data};
my $monlist = $monstat->{monmap}->{mons};
my $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, $rados);
@@ -520,7 +527,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 => 'quorum_status' });
+ $monstat = $rados->mon_command({ prefix => 'quorum_status' })->{data};
$monlist = $monstat->{monmap}->{mons};
my $addrs = [];
diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
index 93433b3a..d38c4ced 100644
--- a/PVE/API2/Ceph/OSD.pm
+++ b/PVE/API2/Ceph/OSD.pm
@@ -30,7 +30,7 @@ my $nodename = PVE::INotify::nodename();
my $get_osd_status = sub {
my ($rados, $osdid) = @_;
- my $stat = $rados->mon_command({ prefix => 'osd dump' });
+ my $stat = $rados->mon_command({ prefix => 'osd dump' })->{data};
my $osdlist = $stat->{osds} || [];
@@ -51,7 +51,7 @@ my $get_osd_status = sub {
my $get_osd_usage = sub {
my ($rados) = @_;
- my $osdlist = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 'osds' ]});
+ my $osdlist = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 'osds' ]})->{data};
if (!($osdlist && ref($osdlist))) {
warn "got unknown result format for 'pg dump osds' command\n";
return [];
@@ -95,7 +95,7 @@ __PACKAGE__->register_method ({
PVE::Ceph::Tools::check_ceph_inited();
my $rados = PVE::RADOS->new();
- my $res = $rados->mon_command({ prefix => 'osd tree' });
+ my $res = $rados->mon_command({ prefix => 'osd tree' })->{data};
die "no tree nodes found\n" if !($res && $res->{nodes});
@@ -103,7 +103,7 @@ __PACKAGE__->register_method ({
my $osd_usage = $get_osd_usage->($rados);
- my $osdmetadata_res = $rados->mon_command({ prefix => 'osd metadata' });
+ my $osdmetadata_res = $rados->mon_command({ prefix => 'osd metadata' })->{data};
my $osdmetadata = { map { $_->{id} => $_ } @$osdmetadata_res };
my $hostversions = PVE::Ceph::Services::get_ceph_versions();
@@ -350,7 +350,7 @@ __PACKAGE__->register_method ({
# get necessary ceph infos
my $rados = PVE::RADOS->new();
- my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+ my $monstat = $rados->mon_command({ prefix => 'quorum_status' })->{data};
die "unable to get fsid\n" if !$monstat->{monmap} || !$monstat->{monmap}->{fsid};
my $fsid = $monstat->{monmap}->{fsid};
@@ -366,7 +366,7 @@ __PACKAGE__->register_method ({
'mon' => 'allow profile bootstrap-osd'
],
format => 'plain',
- });
+ })->{data};
file_set_contents($ceph_bootstrap_osd_keyring, $bindata);
};
@@ -574,7 +574,7 @@ __PACKAGE__->register_method ({
my $rados = PVE::RADOS->new();
my $osd_belongs_to_node = osd_belongs_to_node(
- $rados->mon_command({ prefix => 'osd tree' }),
+ $rados->mon_command({ prefix => 'osd tree' })->{data},
$param->{node},
$osdid,
);
diff --git a/PVE/API2/Ceph/Pools.pm b/PVE/API2/Ceph/Pools.pm
index 002f7893..ed384d6f 100644
--- a/PVE/API2/Ceph/Pools.pm
+++ b/PVE/API2/Ceph/Pools.pm
@@ -21,8 +21,7 @@ my $get_autoscale_status = sub {
$rados = PVE::RADOS->new() if !defined($rados);
- my $autoscale = $rados->mon_command({
- prefix => 'osd pool autoscale-status'});
+ my $autoscale = $rados->mon_command({ prefix => 'osd pool autoscale-status' })->{data};
my $data;
foreach my $p (@$autoscale) {
@@ -132,7 +131,7 @@ __PACKAGE__->register_method ({
my $rados = PVE::RADOS->new();
my $stats = {};
- my $res = $rados->mon_command({ prefix => 'df' });
+ my $res = $rados->mon_command({ prefix => 'df' })->{data};
foreach my $d (@{$res->{pools}}) {
next if !$d->{stats};
@@ -140,8 +139,8 @@ __PACKAGE__->register_method ({
$stats->{$d->{id}} = $d->{stats};
}
- $res = $rados->mon_command({ prefix => 'osd dump' });
- my $rulestmp = $rados->mon_command({ prefix => 'osd crush rule dump'});
+ $res = $rados->mon_command({ prefix => 'osd dump' })->{data};
+ my $rulestmp = $rados->mon_command({ prefix => 'osd crush rule dump'})->{data};
my $rules = {};
for my $rule (@$rulestmp) {
@@ -566,7 +565,7 @@ __PACKAGE__->register_method ({
prefix => 'osd pool get',
pool => "$pool",
var => 'all',
- });
+ })->{data};
my $data = {
id => $res->{pool_id},
@@ -593,7 +592,7 @@ __PACKAGE__->register_method ({
if ($verbose) {
my $stats;
- my $res = $rados->mon_command({ prefix => 'df' });
+ my $res = $rados->mon_command({ prefix => 'df' })->{data};
# pg_autoscaler module is not enabled in Nautilus
# avoid partial read further down, use new rados instance
@@ -606,7 +605,10 @@ __PACKAGE__->register_method ({
$data->{statistics} = $d->{stats};
}
- my $apps = $rados->mon_command({ prefix => "osd pool application get", pool => "$pool", });
+ my $apps = $rados->mon_command({
+ prefix => "osd pool application get",
+ pool => "$pool",
+ })->{data};
$data->{application_list} = [ keys %$apps ];
}
diff --git a/PVE/API2/Cluster/Ceph.pm b/PVE/API2/Cluster/Ceph.pm
index 7f825003..e48626eb 100644
--- a/PVE/API2/Cluster/Ceph.pm
+++ b/PVE/API2/Cluster/Ceph.pm
@@ -96,7 +96,7 @@ __PACKAGE__->register_method ({
}
# get data from metadata call and merge 'our' data
- my $services = $rados->mon_command({ prefix => "$type metadata" });
+ my $services = $rados->mon_command({ prefix => "$type metadata" })->{data};
for my $service ( @$services ) {
my $hostname = $service->{hostname};
next if !defined($hostname); # can happen if node is dead
@@ -115,7 +115,7 @@ __PACKAGE__->register_method ({
$res->{$type} = $data;
}
- $res->{osd} = $rados->mon_command({ prefix => "osd metadata" });
+ $res->{osd} = $rados->mon_command({ prefix => "osd metadata" })->{data};
return $res;
}
@@ -152,7 +152,7 @@ my $get_current_set_flags = sub {
$rados //= PVE::RADOS->new();
- my $stat = $rados->mon_command({ prefix => 'osd dump' });
+ my $stat = $rados->mon_command({ prefix => 'osd dump' })->{data};
my $setflags = $stat->{flags} // '';
return { map { $_ => 1 } PVE::Tools::split_list($setflags) };
};
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 995cfcd5..0aa390ef 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -77,7 +77,7 @@ __PACKAGE__->register_method ({
$pools = PVE::Ceph::Tools::ls_pools(undef, $rados);
$monstat = PVE::Ceph::Services::get_services_info('mon', undef, $rados);
$mdsstat = PVE::Ceph::Services::get_services_info('mds', undef, $rados);
- $osdstat = $rados->mon_command({ prefix => 'osd metadata' });
+ $osdstat = $rados->mon_command({ prefix => 'osd metadata' })->{data};
};
warn "Error gathering ceph info, already purged? Message: $@" if $@;
@@ -291,7 +291,7 @@ __PACKAGE__->register_method ({
if ($param->{'remove-storages'}) {
my $defaultfs;
- my $fs_dump = $rados->mon_command({ prefix => "fs dump" });
+ my $fs_dump = $rados->mon_command({ prefix => "fs dump" })->{data};
for my $fs ($fs_dump->{filesystems}->@*) {
next if $fs->{id} != $fs_dump->{default_fscid};
$defaultfs = $fs->{mdsmap}->{fs_name};
diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index cda13c6a..8fe62cb1 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -147,7 +147,7 @@ sub get_services_info {
return $result;
}
- my $metadata = $rados->mon_command({ prefix => "$type metadata" });
+ my $metadata = $rados->mon_command({ prefix => "$type metadata" })->{data};
foreach my $info (@$metadata) {
my $id = $info->{name} // $info->{id};
my $service = $result->{$id};
@@ -197,7 +197,7 @@ sub get_cluster_mds_state {
$mds_state->{$mds->{name}} = $state;
};
- my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
+ my $mds_dump = $rados->mon_command({ prefix => 'mds stat' })->{data};
my $fsmap = $mds_dump->{fsmap};
@@ -225,7 +225,7 @@ sub is_mds_active {
$rados = PVE::RADOS->new();
}
- my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
+ my $mds_dump = $rados->mon_command({ prefix => 'mds stat' })->{data};
my $fsmap = $mds_dump->{fsmap}->{filesystems};
if (!($fsmap && scalar(@$fsmap) > 0)) {
@@ -280,7 +280,7 @@ sub create_mds {
entity => $service_name,
caps => $priv,
format => 'plain',
- });
+ })->{data};
PVE::Tools::file_set_contents($service_keyring, $output);
@@ -357,7 +357,7 @@ sub create_mgr {
mds => 'allow *',
],
format => 'plain'
- });
+ })->{data};
PVE::Tools::file_set_contents($mgrkeyring, $output);
print "setting owner for directory\n";
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 36d7788a..85306328 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -78,7 +78,7 @@ sub get_cluster_versions {
my $rados = PVE::RADOS->new();
my $cmd = $service ? "$service versions" : 'versions';
- return $rados->mon_command({ prefix => $cmd });
+ return $rados->mon_command({ prefix => $cmd })->{data};
}
sub get_config {
@@ -282,7 +282,7 @@ sub ls_pools {
$rados = PVE::RADOS->new();
}
- my $res = $rados->mon_command({ prefix => "osd lspools" });
+ my $res = $rados->mon_command({ prefix => "osd lspools" })->{data};
return $res;
}
@@ -319,7 +319,7 @@ sub ls_fs {
$rados = PVE::RADOS->new();
}
- my $res = $rados->mon_command({ prefix => "fs ls" });
+ my $res = $rados->mon_command({ prefix => "fs ls" })->{data};
return $res;
}
@@ -420,7 +420,7 @@ sub get_db_wal_sizes {
my $res = {};
my $rados = PVE::RADOS->new();
- my $db_config = $rados->mon_command({ prefix => 'config-key dump', key => 'config/' });
+ my $db_config = $rados->mon_command({ prefix => 'config-key dump', key => 'config/' })->{data};
$res->{db} = $db_config->{"config/osd/bluestore_block_db_size"} //
$db_config->{"config/global/bluestore_block_db_size"};
@@ -520,12 +520,12 @@ 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' });
+ my $status = $rados->mon_command({ prefix => 'status' })->{data};
+ $status->{health} = $rados->mon_command({ prefix => 'health', detail => 'detail' })->{data};
if (!exists $status->{monmap}->{mons}) { # octopus moved most info out of status, re-add
- $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' });
- $status->{mgrmap} = $rados->mon_command({ prefix => 'mgr dump' });
+ $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' })->{data};
+ $status->{mgrmap} = $rados->mon_command({ prefix => 'mgr dump' })->{data};
}
return $status;
--
2.30.2
next prev parent reply other threads:[~2022-03-25 10:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 10:55 [pve-devel] [PATCH v2 librados2-perl storage manager 0/7] Add Ceph safety checks Aaron Lauterer
2022-03-25 10:55 ` [pve-devel] [PATCH v2 librados2-perl 1/7] mon_command: refactor to pass all data to perl Aaron Lauterer
2022-03-25 10:55 ` [pve-devel] [PATCH v2 librados2-perl 2/7] mon_command: optionally ignore errors Aaron Lauterer
2022-03-25 10:55 ` [pve-devel] [PATCH v2 storage 3/7] rbd: adapt to changed rados mon_command return values Aaron Lauterer
2022-03-25 10:55 ` Aaron Lauterer [this message]
2022-03-25 10:55 ` [pve-devel] [PATCH v2 manager 5/7] api: ceph: add cmd-safety endpoint Aaron Lauterer
2022-03-25 10:55 ` [pve-devel] [PATCH v2 manager 6/7] ui: osd: warn if removal could be problematic Aaron Lauterer
2022-03-25 10:55 ` [pve-devel] [PATCH v2 manager 7/7] ui: osd: mon: mds: warn if stop/destroy actions are problematic Aaron Lauterer
2022-11-07 13:18 ` [pve-devel] [PATCH v2 librados2-perl storage manager 0/7] Add Ceph safety checks Aaron Lauterer
2022-11-17 10:35 ` Thomas Lamprecht
2022-11-17 17:46 ` [pve-devel] partially-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=20220325105510.3262101-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.