]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: stop conflicting daemon when deploying to a specific port
authorSage Weil <sage@newdream.net>
Wed, 17 Mar 2021 19:39:15 +0000 (15:39 -0400)
committerSage Weil <sage@newdream.net>
Fri, 19 Mar 2021 14:00:27 +0000 (09:00 -0500)
If we are deploying a daemon to bind to a specific port and there is
an existing daemon we are removing that also binds to that port, stop
it first.  Unless we are both binding to different IPs.

This resolves the case where daemons bind to * and we redeploy with a
subnet to bind to.  It would eventually converge before, but would
throw a bind error in the process and take longer.

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit a2b7587e04651fd6e3409c421ee9c6cbaa020479)

src/pybind/mgr/cephadm/serve.py

index c442f3092a42d74b1c75a21742888bb1e45bee0c..0e986007f70b0a49075194a4d8d51bfd87f27be2 100644 (file)
@@ -588,6 +588,23 @@ class CephadmServe:
 
         for slot in slots_to_add:
             for daemon_type in service_to_daemon_types(service_type):
+                # first remove daemon on conflicting port?
+                if slot.port:
+                    for d in daemons_to_remove:
+                        if d.hostname != slot.hostname or d.ports != [slot.port]:
+                            continue
+                        if d.ip and slot.ip and d.ip != slot.ip:
+                            continue
+                        self.log.info(
+                            f'Removing {d.name()} before deploying to {slot} to avoid a port conflict'
+                        )
+                        # NOTE: we don't check ok-to-stop here to avoid starvation if
+                        # there is only 1 gateway.
+                        self._remove_daemon(d.name(), d.hostname)
+                        daemons_to_remove.remove(d)
+                        break
+
+                # deploy new daemon
                 daemon_id = self.mgr.get_unique_name(
                     daemon_type,
                     slot.hostname,