Comment 5 for bug 1858667

Revision history for this message
melanie witt (melwitt) wrote :

For posterity, going to include why this happened, as discussed in #openstack-nova earlier today [1]:

In the nova-compute _poll_unconfirmed_resizes periodic task, we are calling a nova.compute.api.API method, confirm_resize [2].

Typically, in nova-api we call set_target_cell to target a RequestContext for the duration of the request. In "real life" this lasts until until the RPC boundary, where it is then lost. Then, in nova-compute, we need not target to a cell because nova-compute is local to a cell.

In the func test environment, we don't have real RPC, so when something is targeted in nova-api by set_target_cell, the CheatingSerializer used in the test fixtures will carry over the targeted RequestContext from nova-api -> nova-compute, unlike "real life". We do this so that nova-compute in a func test accesses the correct cell database that is normally "local" in real life.

This normally works fine and when we call periodic tasks manually in func tests, we use target_cell to access the correct cell database because we're not local to a cell like "real life".

The problem arose because in the specific proposed patch, it is adding a target_cell call to the nova.compute.api.API.confirm_resize method [3]. So when the periodic task in the func test is manually called with target_cell, we get two nested calls to target_cell, the second of which causes the exception to be raised.

As discussed in #openstack-nova [1], probably the right thing to do here longer term is create a new inner method that nova-compute specific code always calls (instead of the nova.compute.api.API method), and then nova.compute.api.API can just target to a cell and call the inner method.

[1] http://eavesdrop.openstack.org/irclogs/%23openstack-nova/%23openstack-nova.2020-07-15.log.html#t2020-07-15T15:31:08
[2] https://github.com/openstack/nova/blob/1fa6799e4171d7c93f4d6330f2437891733d7d27/nova/compute/manager.py#L9093
[3] https://review.opendev.org/#/c/699291/8/nova/compute/api.py@3715