Skip to content

Commit c7c62bf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Deploy healthcheck middleware as app instead of filter"
2 parents 79c7eff + ce217a2 commit c7c62bf

File tree

7 files changed

+63
-25
lines changed

7 files changed

+63
-25
lines changed

doc/source/admin/configuring.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ Healthcheck Middleware
3535
This piece of middleware creates an endpoint that allows a load balancer
3636
to probe if the API endpoint should be available at the node or not.
3737

38-
The healthcheck middleware should be placed early in the pipeline. Which
39-
is located in your ``api-paste.ini`` under a section called
40-
``[filter:healthcheck]``. It should look like this::
38+
The healthcheck middleware should be deployed as a paste application
39+
application. Which is located in your ``api-paste.ini`` under a section called
40+
``[app:healthcheck]``. It should look like this::
4141

42-
[filter:healthcheck]
43-
paste.filter_factory = oslo_middleware:Healthcheck.factory
42+
[app:healthcheck]
43+
paste.app_factory = oslo_middleware:Healthcheck.app_factory
4444
backends = disable_by_file
4545
disable_by_file_path = /etc/magnum/healthcheck_disable
4646

47-
The main pipeline using this filter should look something like this also
47+
The main pipeline using this application should look something like this also
4848
defined in the ``api-paste.ini``::
4949

50-
[pipeline:main]
51-
pipeline = cors healthcheck request_id authtoken api_v1
50+
[composite:main]
51+
paste.composite_factory = magnum.api:root_app_factory
52+
/: api
53+
/healthcheck: healthcheck
5254

5355
If you wish to disable a middleware without taking it out of the
5456
pipeline, you can create a file under the file path defined by

etc/magnum/api-paste.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
[pipeline:main]
2-
pipeline = cors healthcheck http_proxy_to_wsgi request_id osprofiler authtoken api_v1
1+
[composite:main]
2+
paste.composite_factory = magnum.api:root_app_factory
3+
/: api
4+
/healthcheck: healthcheck
5+
6+
[pipeline:api]
7+
pipeline = cors http_proxy_to_wsgi request_id osprofiler authtoken api_v1
38

49
[app:api_v1]
510
paste.app_factory = magnum.api.app:app_factory
@@ -18,8 +23,8 @@ paste.filter_factory = oslo_middleware:RequestId.factory
1823
paste.filter_factory = oslo_middleware.cors:filter_factory
1924
oslo_config_project = magnum
2025

21-
[filter:healthcheck]
22-
paste.filter_factory = oslo_middleware:Healthcheck.factory
26+
[app:healthcheck]
27+
paste.app_factory = oslo_middleware:Healthcheck.app_factory
2328
backends = disable_by_file
2429
disable_by_file_path = /etc/magnum/healthcheck_disable
2530

magnum/api/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
import paste.urlmap
13+
14+
15+
def root_app_factory(loader, global_conf, **local_conf):
16+
return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)

magnum/tests/unit/api/controllers/auth-paste.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
[pipeline:main]
2-
pipeline = cors healthcheck request_id authtoken api_v1
1+
[composite:main]
2+
paste.composite_factory = magnum.api:root_app_factory
3+
/: api
4+
/healthcheck: healthcheck
5+
6+
[pipeline:api]
7+
pipeline = cors request_id authtoken api_v1
38

49
[app:api_v1]
510
paste.app_factory = magnum.api.app:app_factory
@@ -14,7 +19,7 @@ paste.filter_factory = oslo_middleware:RequestId.factory
1419
paste.filter_factory = oslo_middleware.cors:filter_factory
1520
oslo_config_project = magnum
1621

17-
[filter:healthcheck]
18-
paste.filter_factory = oslo_middleware:Healthcheck.factory
22+
[app:healthcheck]
23+
paste.app_factory = oslo_middleware:Healthcheck.app_factory
1924
backends = disable_by_file
2025
disable_by_file_path = /tmp/magnum_healthcheck_disable

magnum/tests/unit/api/controllers/auth-root-access.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
[pipeline:main]
2-
pipeline = cors healthcheck request_id authtoken api_v1
1+
[composite:main]
2+
paste.composite_factory = magnum.api:root_app_factory
3+
/: api
4+
/healthcheck: healthcheck
5+
6+
[pipeline:api]
7+
pipeline = cors request_id authtoken api_v1
38

49
[app:api_v1]
510
paste.app_factory = magnum.api.app:app_factory
@@ -15,7 +20,7 @@ paste.filter_factory = oslo_middleware:RequestId.factory
1520
paste.filter_factory = oslo_middleware.cors:filter_factory
1621
oslo_config_project = magnum
1722

18-
[filter:healthcheck]
19-
paste.filter_factory = oslo_middleware:Healthcheck.factory
23+
[app:healthcheck]
24+
paste.app_factory = oslo_middleware:Healthcheck.app_factory
2025
backends = disable_by_file
2126
disable_by_file_path = /tmp/magnum_healthcheck_disable

magnum/tests/unit/api/controllers/auth-v1-access.ini

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
[pipeline:main]
2-
pipeline = cors healthcheck request_id authtoken api_v1
1+
[composite:main]
2+
paste.composite_factory = magnum.api:root_app_factory
3+
/: api
4+
/healthcheck: healthcheck
5+
6+
[pipeline:api]
7+
pipeline = cors request_id authtoken api_v1
38

49
[app:api_v1]
510
paste.app_factory = magnum.api.app:app_factory
@@ -15,7 +20,7 @@ paste.filter_factory = oslo_middleware:RequestId.factory
1520
paste.filter_factory = oslo_middleware.cors:filter_factory
1621
oslo_config_project = magnum
1722

18-
[filter:healthcheck]
19-
paste.filter_factory = oslo_middleware:Healthcheck.factory
23+
[app:healthcheck]
24+
paste.app_factory = oslo_middleware:Healthcheck.app_factory
2025
backends = disable_by_file
2126
disable_by_file_path = /tmp/magnum_healthcheck_disable

magnum/tests/unit/api/controllers/test_root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def setUp(self):
195195
# Read current file and create new one
196196
config = ConfigParser.RawConfigParser()
197197
config.read(self.get_path(paste_ini))
198-
config.set('filter:healthcheck',
198+
config.set('app:healthcheck',
199199
'disable_by_file_path',
200200
self.tempdir + "/disable")
201201
with open(self.tempdir + "/paste.ini", 'wt') as configfile:

0 commit comments

Comments
 (0)