There are also places like nova/tests/unit/db/test_db_api.py:_create_aggregate which calls get_admin_context() as a default value for an argument to a function.
Tackling all of the places that call get_admin_context() at import time would likely fix the problem at the expense of a lot of work, but it also won't prevent new uses from sneaking in.
I guess clearing out the context is the best short term solution.
We should really rethink how contexts work because side-effects like this are bad.
There are also places like nova/tests/ unit/db/ test_db_ api.py: _create_ aggregate which calls get_admin_context() as a default value for an argument to a function.
Tackling all of the places that call get_admin_context() at import time would likely fix the problem at the expense of a lot of work, but it also won't prevent new uses from sneaking in.
I guess clearing out the context is the best short term solution.
We should really rethink how contexts work because side-effects like this are bad.