]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard,prometheus: fix handling of server_addr 43631/head
authorScott Shambarger <devel@shambarger.net>
Sun, 8 Aug 2021 20:10:15 +0000 (13:10 -0700)
committerAvan Thakkar <athakkar@redhat.com>
Sat, 23 Oct 2021 12:00:48 +0000 (17:30 +0530)
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>
(cherry picked from commit de9743244ddfe6715d9f39f9ece227bb0634bac2)

src/pybind/mgr/dashboard/module.py
src/pybind/mgr/prometheus/module.py

index de9b536bfc88fb6a96ba4e1ae693a61cb502500d..67b55000a07b4a664334bec161b6107c47557c60 100644 (file)
@@ -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,
index c8b7a5302e53b865f08e5c2535a87ab67abafb6c..e6823e3d996c8fa995719a8665a7c8db0bc90528 100644 (file)
@@ -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()