From de9743244ddfe6715d9f39f9ece227bb0634bac2 Mon Sep 17 00:00:00 2001 From: Scott Shambarger Date: Sun, 8 Aug 2021 13:10:15 -0700 Subject: [PATCH] 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 --- src/pybind/mgr/dashboard/module.py | 4 ++-- src/pybind/mgr/prometheus/module.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 9d389eb25740..71551ed14e0b 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -110,8 +110,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; ' @@ -194,6 +192,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 746ad9ceaf3a..cfc7bff00db4 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1394,17 +1394,17 @@ class Module(MgrModule): else: self.log.info('Cache disabled') + 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() -- 2.47.3