On 4/10/19 10:35 AM, Alwin Antreich wrote:
> 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.antre...@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;
> +    }

looks pretty similar to my checks in API/Ceph/MON's $find_mon_ip ;-)

If you re-add this here I would maybe name it better, or just do it as closure
in the Ceph API status call, if no other uses are to expected now. Also the 
error
could be made a bit more understandable for this context, something along the 
lines 
off "Ceph public network seems down" further, this could be only done if the 
rados
command really times out, and be passed back as common $status element?

> +
> +    return 1;
> +}
> +
>  sub check_ceph_enabled {
>      my ($noerr) = @_;
>  
> 


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to