From: Scott Shambarger Date: Sun, 8 Aug 2021 20:10:15 +0000 (-0700) Subject: mgr/dashboard,prometheus: fix handling of server_addr X-Git-Tag: v16.2.7~59^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2d45c8fc841ee0e13bddeea1660f514200b1973f;p=ceph.git mgr/dashboard,prometheus: fix handling of server_addr Commit 157a7b4 corrected the URI published by dashboard/prometheus to use get_mgr_ip() if the address was the wildcard (eg ::). However, the change also affected the cherrypy server.socket_host config value, so the modules could no longer bind to a wildcard. This patch corrects the commit to not affect the cherrypy config. It also further corrects the dashboard URI fix to handle the 0.0.0.0 wildcard case (prometheus already had this behavior). Fixes: 157a7b4183dbd888f106c613a758409d7e07b917 Fixes: http://tracker.ceph.com/issues/52002 Signed-off-by: Scott Shambarger (cherry picked from commit de9743244ddfe6715d9f39f9ece227bb0634bac2) --- diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index de9b536bfc88f..67b55000a07b4 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -109,8 +109,6 @@ class CherryPyConfig(object): else: server_port = self.get_localized_module_option('ssl_server_port', 8443) # type: ignore - if server_addr == '::': - server_addr = self.get_mgr_ip() # type: ignore if server_addr is None: raise ServerConfigException( 'no server_addr configured; ' @@ -193,6 +191,8 @@ class CherryPyConfig(object): self._url_prefix = prepare_url_prefix(self.get_module_option( # type: ignore 'url_prefix', default='')) + if server_addr in ['::', '0.0.0.0']: + server_addr = self.get_mgr_ip() # type: ignore base_url = build_url( scheme='https' if use_ssl else 'http', host=server_addr, diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index c8b7a5302e53b..e6823e3d996c8 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1374,17 +1374,17 @@ class Module(MgrModule): self.metrics_thread.start() + cherrypy.config.update({ + 'server.socket_host': server_addr, + 'server.socket_port': server_port, + 'engine.autoreload.on': False + }) # Publish the URI that others may use to access the service we're # about to start serving if server_addr in ['::', '0.0.0.0']: server_addr = self.get_mgr_ip() self.set_uri(build_url(scheme='http', host=server_addr, port=server_port, path='/')) - cherrypy.config.update({ - 'server.socket_host': server_addr, - 'server.socket_port': server_port, - 'engine.autoreload.on': False - }) cherrypy.tree.mount(Root(), "/") self.log.info('Starting engine...') cherrypy.engine.start()