Initialize global data separately and run_once in WSGI app init
NOTE(melwitt): This is a combination of two changes to avoid
intermittent test failure that was introduced by the original bug fix,
and was fixed by change I2bd360dcc6501feea7baf02d4510b282205fc061.
We have discovered that if an exception is raised at any point during
the running of the init_application WSGI script in an apache/mod_wsgi
Daemon Mode environment, it will prompt apache/mod_wsgi to re-run the
script without starting a fresh python process. Because we initialize
global data structures during app init, subsequent runs of the script
blow up as some global data do *not* support re-initialization. It is
anyway not safe to assume that init of global data is safe to run
multiple times.
This mod_wsgi behavior appears to be a special situation that does not
behave the same as a normal reload in Daemon Mode as the script file is
being reloaded upon failure instead of the daemon process being
shutdown and restarted as described in the documentation [1].
In order to handle this situation, we can move the initialization of
global data structures to a helper method that is decorated to run only
once per python interpreter instance. This way, we will not attempt to
re-initialize global data that are not safe to init more than once.
Since I2bd360dcc6501feea7baf02d4510b282205fc061 there is a global state
set during the wsgi_app init making our unit test cases
non-deterministic based on the order of them. This patch makes sure
that the global state is reset for each test case.
Closes-Bug: #1921098
(cherry picked from commit bc2c19bb2db901af0c48d34fb15a335f4e343361)
Change-Id: I2bd360dcc6501feea7baf02d4510b282205fc061
(cherry picked from commit 7c9edc02eda45aafbbb539b759e6b92f7aeb5ea8)
Reviewed: https:/ /review. opendev. org/c/openstack /nova/+ /785059 /opendev. org/openstack/ nova/commit/ e3085fa6310ddea afa493c3f718aab 0ce64f0994
Committed: https:/
Submitter: "Zuul (22348)"
Branch: stable/victoria
commit e3085fa6310ddea afa493c3f718aab 0ce64f0994
Author: Hervé Beraud <email address hidden>
Date: Thu Jun 4 09:49:59 2020 +0200
Initialize global data separately and run_once in WSGI app init
NOTE(melwitt): This is a combination of two changes to avoid eea7baf02d4510b 282205fc061.
intermittent test failure that was introduced by the original bug fix,
and was fixed by change I2bd360dcc6501f
We have discovered that if an exception is raised at any point during
the running of the init_application WSGI script in an apache/mod_wsgi
Daemon Mode environment, it will prompt apache/mod_wsgi to re-run the
script without starting a fresh python process. Because we initialize
global data structures during app init, subsequent runs of the script
blow up as some global data do *not* support re-initialization. It is
anyway not safe to assume that init of global data is safe to run
multiple times.
This mod_wsgi behavior appears to be a special situation that does not
behave the same as a normal reload in Daemon Mode as the script file is
being reloaded upon failure instead of the daemon process being
shutdown and restarted as described in the documentation [1].
In order to handle this situation, we can move the initialization of
global data structures to a helper method that is decorated to run only
once per python interpreter instance. This way, we will not attempt to
re-initialize global data that are not safe to init more than once.
Co-Authored-By: Michele Baldessari <email address hidden>
Co-Authored-By: melanie witt <email address hidden>
Conflicts:
nova/api/ openstack/ wsgi_app. py
NOTE(melwitt): The conflict is because change 2da33d512d7c283 4f0bb2e2a9b9654 (Support sys.argv in wsgi
If4783adda9
app) is not in Victoria.
Closes-Bug: #1882094
[1] https:/ /modwsgi. readthedocs. io/en/develop/ user-guides/ reloading- source- code.html# reloading- in-daemon- mode
Reset global wsgi app state in unit test
Since I2bd360dcc6501f eea7baf02d4510b 282205fc061 there is a global state deterministic based on the order of them. This patch makes sure
set during the wsgi_app init making our unit test cases
non-
that the global state is reset for each test case.
Closes-Bug: #1921098 f0c48d34fb15a33 5f4e343361)
(cherry picked from commit bc2c19bb2db901a
Change-Id: I2bd360dcc6501f eea7baf02d4510b 282205fc061 fbbb539b759e6b9 2f7aeb5ea8)
(cherry picked from commit 7c9edc02eda45aa