From: Noah Watkins Date: Fri, 22 Feb 2019 22:13:47 +0000 (-0800) Subject: mgr/dashboard: fix for using '::' on hosts without ipv6 X-Git-Tag: v14.1.1~65^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26635%2Fhead;p=ceph.git mgr/dashboard: fix for using '::' on hosts without ipv6 CherryPy throws an uncaught exception using '::' when the host does not have an ipv6 loopback address. This is currently the case in kubernetes. This patch disables the routine in cherrypy that performs the validation that requested server ports are actually bound. Signed-off-by: Noah Watkins --- diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index a9793bf61b84..9a6f3748324b 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -47,6 +47,19 @@ if cherrypy is not None: HTTPConnection.__init__ = fixed_init +# When the CherryPy server in 3.2.2 (and later) starts it attempts to verify +# that the ports its listening on are in fact bound. When using the any address +# "::" it tries both ipv4 and ipv6, and in some environments (e.g. kubernetes) +# ipv6 isn't yet configured / supported and CherryPy throws an uncaught +# exception. +if cherrypy is not None: + v = StrictVersion(cherrypy.__version__) + # the issue was fixed in 3.2.3. it's present in 3.2.2 (current version on + # centos:7) and back to at least 3.0.0. + if StrictVersion("3.1.2") <= v < StrictVersion("3.2.3"): + # https://github.com/cherrypy/cherrypy/issues/1100 + from cherrypy.process import servers + servers.wait_for_occupied_port = lambda host, port: None if 'COVERAGE_ENABLED' in os.environ: import coverage diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index ab92bee15112..e0dc2cc5a0f7 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1,4 +1,5 @@ import cherrypy +from distutils.version import StrictVersion import json import errno import math @@ -17,6 +18,19 @@ from rbd import RBD DEFAULT_ADDR = '::' DEFAULT_PORT = 9283 +# When the CherryPy server in 3.2.2 (and later) starts it attempts to verify +# that the ports its listening on are in fact bound. When using the any address +# "::" it tries both ipv4 and ipv6, and in some environments (e.g. kubernetes) +# ipv6 isn't yet configured / supported and CherryPy throws an uncaught +# exception. +if cherrypy is not None: + v = StrictVersion(cherrypy.__version__) + # the issue was fixed in 3.2.3. it's present in 3.2.2 (current version on + # centos:7) and back to at least 3.0.0. + if StrictVersion("3.1.2") <= v < StrictVersion("3.2.3"): + # https://github.com/cherrypy/cherrypy/issues/1100 + from cherrypy.process import servers + servers.wait_for_occupied_port = lambda host, port: None # cherrypy likes to sys.exit on error. don't let it take us down too! def os_exit_noop(*args, **kwargs):