From: John Mulligan Date: Tue, 11 Jul 2023 20:29:44 +0000 (-0400) Subject: pybind/mgr/cephadm: move haproxy client addrs to func X-Git-Tag: v18.2.1~326^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=607dfacb790667c75ccf17d80dd60784524743e1;p=ceph.git pybind/mgr/cephadm: move haproxy client addrs to func Move the list comprehension that gets the list of IP addresses for the haproxy_hosts list to a separate function. This is in preparation for making the logic more complex in a later commit. Signed-off-by: John Mulligan (cherry picked from commit b1d2bb6ec53c2aa3574db2f5d3dc3878d2969a58) --- diff --git a/src/pybind/mgr/cephadm/services/nfs.py b/src/pybind/mgr/cephadm/services/nfs.py index 5a997ddda123..715a0db72973 100644 --- a/src/pybind/mgr/cephadm/services/nfs.py +++ b/src/pybind/mgr/cephadm/services/nfs.py @@ -116,18 +116,7 @@ class NFSService(CephService): "haproxy_hosts": [], } if spec.enable_haproxy_protocol: - # NB: Ideally, we would limit the list to IPs on hosts running - # haproxy/ingress only, but due to the nature of cephadm today - # we'd "only know the set of haproxy hosts after they've been - # deployed" (quoth @adk7398). As it is today we limit the list - # of hosts we know are managed by cephadm. That ought to be - # good enough to prevent acceping haproxy protocol messages - # from "rouge" systems that are not under our control. At - # least until we learn otherwise. - context["haproxy_hosts"] = [ - self.mgr.inventory.get_addr(h) - for h in self.mgr.inventory.keys() - ] + context["haproxy_hosts"] = self._haproxy_hosts() logger.debug("selected haproxy_hosts: %r", context["haproxy_hosts"]) return self.mgr.template.render('services/nfs/ganesha.conf.j2', context) @@ -311,3 +300,17 @@ class NFSService(CephService): stderr=subprocess.PIPE, timeout=10 ) + + def _haproxy_hosts(self) -> List[str]: + # NB: Ideally, we would limit the list to IPs on hosts running + # haproxy/ingress only, but due to the nature of cephadm today + # we'd "only know the set of haproxy hosts after they've been + # deployed" (quoth @adk7398). As it is today we limit the list + # of hosts we know are managed by cephadm. That ought to be + # good enough to prevent acceping haproxy protocol messages + # from "rouge" systems that are not under our control. At + # least until we learn otherwise. + return [ + self.mgr.inventory.get_addr(h) + for h in self.mgr.inventory.keys() + ]