]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard,prometheus: fix handling of server_addr 42716/head
authorScott Shambarger <devel@shambarger.net>
Sun, 8 Aug 2021 20:10:15 +0000 (13:10 -0700)
committerScott Shambarger <devel@shambarger.net>
Tue, 14 Sep 2021 17:31:12 +0000 (10:31 -0700)
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 <devel@shambarger.net>
src/pybind/mgr/dashboard/module.py
src/pybind/mgr/prometheus/module.py

index 9d389eb257401f6f85bfe6736cc238a2e4618047..71551ed14e0ba89a466697f6d7e399511dc37ed3 100644 (file)
@@ -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,
index 746ad9ceaf3a503001f7e91781fe292ddae941ee..cfc7bff00db4b92d34bc450f6d15bc2fccccaedc 100644 (file)
@@ -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()