diff --git a/oslo_middleware/healthcheck/__init__.py b/oslo_middleware/healthcheck/__init__.py index 733fd6c..158baff 100644 --- a/oslo_middleware/healthcheck/__init__.py +++ b/oslo_middleware/healthcheck/__init__.py @@ -26,7 +26,6 @@ import sys import traceback import typing as ty -from debtcollector import removals import jinja2 from oslo_utils import reflection from oslo_utils import timeutils @@ -406,7 +405,6 @@ Reason self.oslo_conf.register_opts( opts.HEALTHCHECK_OPTS, group='healthcheck' ) - self._path = self._conf_get('path') self._show_details = self._conf_get('detailed') self._source_ranges = [ ipaddress.ip_network(r) @@ -440,7 +438,6 @@ Reason # always return text/plain (because sending an error from this # middleware actually can cause issues). self._default_accept = 'text/plain' - self._ignore_path = False def _verify_configured_plugins(self) -> None: backends = self._conf_get('backends') @@ -456,17 +453,15 @@ Reason def _conf_get(self, key: str, group: str = 'healthcheck') -> ty.Any: return super()._conf_get(key, group=group) - @removals.remove( # type: ignore - message="The healthcheck middleware must now be configured as " - "an application, not as a filter" - ) @classmethod def factory( - cls, + cls: type[base.MiddlewareType], global_conf: dict[str, ty.Any] | None, **local_conf: ty.Any, - ) -> ty.Callable[[WSGIApplication], base.ConfigurableMiddleware]: - return super().factory(global_conf, **local_conf) + ) -> ty.Callable[[WSGIApplication], base.MiddlewareType]: + raise NotImplementedError( + 'HealthcheckMiddleware should be deployed as an app, not a filter' + ) @classmethod def app_factory( @@ -486,7 +481,6 @@ Reason conf = global_conf.copy() if global_conf else {} conf.update(local_conf) middleware = cls(None, conf) - middleware._ignore_path = True return middleware @staticmethod @@ -629,9 +623,6 @@ Reason self, req: webob.request.Request, ) -> webob.response.Response | None: - if not self._ignore_path and req.path != self._path: - return None - if self._source_ranges: if not req.remote_addr: return None diff --git a/oslo_middleware/healthcheck/opts.py b/oslo_middleware/healthcheck/opts.py index 951e456..b47693f 100644 --- a/oslo_middleware/healthcheck/opts.py +++ b/oslo_middleware/healthcheck/opts.py @@ -14,12 +14,6 @@ from oslo_config import cfg HEALTHCHECK_OPTS = [ - cfg.StrOpt( - 'path', - default='/healthcheck', - deprecated_for_removal=True, - help='The path to respond to healtcheck requests on.', - ), cfg.BoolOpt( 'detailed', default=False, diff --git a/oslo_middleware/tests/test_entry_points.py b/oslo_middleware/tests/test_entry_points.py index 8a64cb7..53e59eb 100644 --- a/oslo_middleware/tests/test_entry_points.py +++ b/oslo_middleware/tests/test_entry_points.py @@ -22,7 +22,6 @@ class TestPasteDeploymentEntryPoints(base.BaseTestCase): 'correlation_id': 'CorrelationId', 'cors': 'CORS', 'debug': 'Debug', - 'healthcheck': 'Healthcheck', 'http_proxy_to_wsgi': 'HTTPProxyToWSGI', 'request_id': 'RequestId', 'sizelimit': 'RequestBodySizeLimiter', diff --git a/oslo_middleware/tests/test_healthcheck.py b/oslo_middleware/tests/test_healthcheck.py index 891e1dc..9a2d32e 100644 --- a/oslo_middleware/tests/test_healthcheck.py +++ b/oslo_middleware/tests/test_healthcheck.py @@ -105,20 +105,9 @@ class HealthcheckTests(test_base.BaseTestCase): self.assertEqual(expected_code, res.status_int) self.assertEqual(expected_body, res.body) - def test_default_path_match(self): + def test_default(self): self._do_test() - def test_default_path_not_match(self): - self._do_test(path='/toto', expected_body=b'Hello, World!!!') - - def test_configured_path_match(self): - conf = {'path': '/hidden_healthcheck'} - self._do_test(conf, path='/hidden_healthcheck') - - def test_configured_path_not_match(self): - conf = {'path': '/hidden_healthcheck'} - self._do_test(conf, path='/toto', expected_body=b'Hello, World!!!') - @mock.patch('oslo_middleware.healthcheck.disable_by_file.LOG') def test_disablefile_unconfigured(self, fake_log): fake_warn = fake_log.warning diff --git a/pyproject.toml b/pyproject.toml index 7457e25..c2aa288 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ catch_errors = "oslo_middleware:CatchErrors.factory" correlation_id = "oslo_middleware:CorrelationId.factory" cors = "oslo_middleware:CORS.factory" debug = "oslo_middleware:Debug.factory" -healthcheck = "oslo_middleware:Healthcheck.factory" http_proxy_to_wsgi = "oslo_middleware:HTTPProxyToWSGI.factory" request_id = "oslo_middleware:RequestId.factory" sizelimit = "oslo_middleware:RequestBodySizeLimiter.factory" diff --git a/releasenotes/notes/healthcheck-app-only-f6442fa7da6dd22e.yaml b/releasenotes/notes/healthcheck-app-only-f6442fa7da6dd22e.yaml new file mode 100644 index 0000000..7b04259 --- /dev/null +++ b/releasenotes/notes/healthcheck-app-only-f6442fa7da6dd22e.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + The HealthCheck middleware no longer supports being deployed as a filter. + It should be deployed as an application.