[pve-devel] [PATCH manager] Ceph status: is public net IP available on host

Alwin Antreich a.antreich at proxmox.com
Wed Apr 10 10:35:42 CEST 2019


Checks if the host has an interface with an IP of ceph's public network
active, when ceph's status is requested.

With this check the status returns a more descriptive message when no
network connection exists, as to just a time out, when the MON could not
be reached.

Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
 PVE/API2/Ceph.pm  |  1 +
 PVE/Ceph/Tools.pm | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 21253276..9374e4b4 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -528,6 +528,7 @@ __PACKAGE__->register_method ({
 	my ($param) = @_;
 
 	PVE::Ceph::Tools::check_ceph_inited();
+	PVE::Ceph::Tools::check_ceph_interface($param->{node});
 
 	my $rados = PVE::RADOS->new();
 	my $status = $rados->mon_command({ prefix => 'status' });
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 5170fd6c..03f9e50b 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -9,6 +9,7 @@ use IO::File;
 
 use PVE::Tools qw(run_command dir_glob_foreach);
 use PVE::RADOS;
+use PVE::Cluster;
 
 my $ccname = 'ceph'; # ceph cluster name
 my $ceph_cfgdir = "/etc/ceph";
@@ -110,6 +111,21 @@ sub check_ceph_inited {
     return 1;
 }
 
+sub check_ceph_interface {
+    my ($node, $noerr) = @_;
+    my $content = PVE::Cluster::cfs_read_file('ceph.conf');
+    my $pubnet = $content->{'global'}->{'public network'};
+
+    my $allowed_ips = PVE::Network::get_local_ip_from_cidr($pubnet);
+    if (scalar(@$allowed_ips) < 1) {
+	die "No active IP found for the requested ceph public network '$pubnet' on node '$node'\n"
+	    if (!$noerr);
+	return undef;
+    }
+
+    return 1;
+}
+
 sub check_ceph_enabled {
     my ($noerr) = @_;
 
-- 
2.11.0





More information about the pve-devel mailing list