Remove filter support of HealthCheck middleware

Deploying HealthCheck middleware as a filter was deprecated long ago[1]
and we are now ready to remove this capability and require users to
deploy it as an application.

[1] 6feaa13610

Change-Id: I788c61e4cfa67ffbc4132fdc5da33a1521987a74
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-09-30 22:03:00 +09:00
committed by Stephen Finucane
parent e666860421
commit 7d1ca5d6b3
6 changed files with 11 additions and 34 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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',

View File

@@ -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

View File

@@ -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"

View File

@@ -0,0 +1,5 @@
---
upgrade:
- |
The HealthCheck middleware no longer supports being deployed as a filter.
It should be deployed as an application.