conf: Add '[api] response_validation' option

We have no schemas yet and thus nothing to use this, but we enable it in
our tests for when we start adding these.

Change-Id: I160ee724459403a10516a356ee860831545d7d65
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-02-29 19:47:08 +00:00
parent 0021b840a2
commit 1a93703623
3 changed files with 42 additions and 1 deletions

View File

@ -396,12 +396,44 @@ so if your hypervisor does not support password injection, set this to False.
""")
]
validation_opts = [
cfg.StrOpt(
"response_validation",
choices=(
(
"error",
"Raise a HTTP 500 (Server Error) for responses that fail "
"schema validation",
),
(
"warn",
"Log a warning for responses that fail schema validation",
),
(
"ignore",
"Ignore schema validation failures",
),
),
default="warn",
help="""\
Configure validation of API responses.
``warn`` is the current recommendation for production environments. This is
expected to change to ``error`` in a future release.
If you find it necessary to enable the ``ignore`` option, please report the
issues you are seeing to the Nova team so we can improve our schemas.
""",
),
]
API_OPTS = (auth_opts +
metadata_opts +
file_opts +
osapi_opts +
os_network_opts +
enable_inst_pw_opts)
enable_inst_pw_opts +
validation_opts)
def register_opts(conf):

View File

@ -58,6 +58,9 @@ class ConfFixture(config_fixture.Config):
# tests.
self.conf.set_default('keep_alive', False, group="wsgi")
# api group
self.conf.set_default('response_validation', 'error', group='api')
# many tests synchronizes on the reception of versioned notifications
self.conf.set_default(
'notification_format', "both", group="notifications")

View File

@ -0,0 +1,6 @@
---
features:
- |
A new configuration option, ``[api] response_validation``, has been added.
This allows operators to configure the behavior of ``nova-api`` when a
response fails schema validation.