[pve-devel] [PATCH storage] Exclude general MON section in get_monaddr_list
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Jan 9 14:04:17 CET 2019
On 1/9/19 11:59 AM, Alwin Antreich wrote:
> If a general MON section exists in the ceph.conf, the get_monaddr_list
> adds a undefined entry and a cephfs storage can't be mounted anymore.
>
> Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
> ---
> PVE/CephConfig.pm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
> index b420fcc..aad2701 100644
> --- a/PVE/CephConfig.pm
> +++ b/PVE/CephConfig.pm
> @@ -107,7 +107,7 @@ sub get_monaddr_list {
> }
>
> my $config = $parse_ceph_file->($configfile);
> - @$server = sort map { $config->{$_}->{'mon addr'} } grep {/mon/} %{$config};
> + @$server = sort map { $config->{$_}->{'mon addr'} } grep {/mon\./} %{$config};
hmm, I had something in my tree for this, just forgot it -.-
rebased it'd be:
----8<----
diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
index aad2701..75c4038 100644
--- a/PVE/CephConfig.pm
+++ b/PVE/CephConfig.pm
@@ -107,9 +107,17 @@ sub get_monaddr_list {
}
my $config = $parse_ceph_file->($configfile);
- @$server = sort map { $config->{$_}->{'mon addr'} } grep {/mon\./} %{$config};
- return join(',', @$server);
+ my $monlist;
+ for my $monid (grep { /mon/ } %{$config}) {
+ if (defined($config->{$monid}->{'mon addr'})) {
+ my $prefix = defined($monlist) ? ',' : '';
+
+ $monlist = "${prefix}$config->{$monid}->{'mon addr'}";
+ }
+ }
+
+ return $monlist;
};
sub hostlist {
--
this ensures that you really only pick those entries with a defined 'mon addr' up,
because theoretically you could have entries without one (even if it may not make
much sense). Yours works naturally too, at the moment at least and it keeps the
code a bit more concise. Maybe @Wolfgang can tie break this ;)
>
> return join(',', @$server);
> };
>
More information about the pve-devel
mailing list