api: ceph: mon: make checking for duplicate addresses more robust

Because $mon->{addr} might come with a port attached (affects monitors
created with PVE 5.4 as reported in the community forum [0]), or even
be a hostname (according to the code in Ceph/Services.pm). Although
the latter shouldn't happen for configurations created by PVE.

[0]: https://forum.proxmox.com/threads/105904/

Fixes: 9e989449 ("api: ceph: mon: fix handling of IPv6 addresses in assert_mon_prerequisites")
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-03-04 14:09:08 +01:00 committed by Thomas Lamprecht
parent ea4d55c99d
commit e6f55a13b0

View File

@ -132,8 +132,10 @@ my $assert_mon_prerequisites = sub {
for my $mon (values %{$monhash}) {
next if !defined($mon->{addr});
my $ip = PVE::Network::canonical_ip($mon->{addr});
$used_ips->{$ip} = 1;
for my $ip ($ips_from_mon_host->($mon->{addr})->@*) {
$ip = PVE::Network::canonical_ip($ip);
$used_ips->{$ip} = 1;
}
}
for my $monip (@{$monips}) {