Fix: ceph: mon_address not considered by new MON

The public_addr option for creating a new MON is only valid for manual
startup (since Ceph Jewel) and is just ignored by ceph-mon during setup.
As the MON is started after the creation through systemd without an IP
specified. It is trying to auto-select an IP.

Before this patch the public_addr was only explicitly written to the
ceph.conf if no public_network was set. The mon_address is only needed
in the config on the first start of the MON.

The ceph-mon itself tries to select an IP on the following conditions.
- no public_network or public_addr is in the ceph.conf
    * startup fails

- public_network is in the ceph.conf
    * with a single network, take the first available IP
    * on multiple networks, walk through the list orderly and start on
      the first network where an IP is found

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
This commit is contained in:
Alwin Antreich 2020-03-11 16:22:36 +01:00 committed by Fabian Grünbichler
parent 45d7f82fa3
commit 78fcb4947d

View File

@ -255,7 +255,7 @@ __PACKAGE__->register_method ({
run_command("monmaptool --create --clobber --addv $monid '[v2:$monaddr:3300,v1:$monaddr:6789]' --print $monmap");
}
run_command("ceph-mon --mkfs -i $monid --monmap $monmap --keyring $mon_keyring --public-addr $ip");
run_command("ceph-mon --mkfs -i $monid --monmap $monmap --keyring $mon_keyring");
run_command("chown ceph:ceph -R $mondir");
};
my $err = $@;
@ -275,11 +275,8 @@ __PACKAGE__->register_method ({
}
$monhost .= " $ip";
$cfg->{global}->{mon_host} = $monhost;
if (!defined($cfg->{global}->{public_network})) {
# if there is no info about the public_network
# we have to set it explicitly for the monitor
$cfg->{$monsection}->{public_addr} = $ip;
}
# The IP is needed in the ceph.conf for the first boot
$cfg->{$monsection}->{public_addr} = $ip;
cfs_write_file('ceph.conf', $cfg);