nova/nova/db
Mark Goddard cbbca58504 Prevent deletion of a compute node belonging to another host
There is a race condition in nova-compute with the ironic virt driver as
nodes get rebalanced. It can lead to compute nodes being removed in the
DB and not repopulated. Ultimately this prevents these nodes from being
scheduled to.

The main race condition involved is in update_available_resources in
the compute manager. When the list of compute nodes is queried, there is
a compute node belonging to the host that it does not expect to be
managing, i.e. it is an orphan. Between that time and deleting the
orphan, the real owner of the compute node takes ownership of it ( in
the resource tracker). However, the node is still deleted as the first
host is unaware of the ownership change.

This change prevents this from occurring by filtering on the host when
deleting a compute node. If another compute host has taken ownership of
a node, it will have updated the host field and this will prevent
deletion from occurring. The first host sees this has happened via the
ComputeHostNotFound exception, and avoids deleting its resource
provider.

Co-Authored-By: melanie witt <melwittt@gmail.com>

Conflicts:
    nova/db/sqlalchemy/api.py

NOTE(melwitt): The conflict is because change
I9f414cf831316b624132d9e06192f1ecbbd3dd78 (db: Copy docs from
'nova.db.*' to 'nova.db.sqlalchemy.*') is not in Wallaby.

NOTE(melwitt): Differences from the cherry picked change from calling
nova.db.api => nova.db.sqlalchemy.api directly are due to the alembic
migration in Xena which looks to have made the nova.db.api interface
obsolete.

Closes-Bug: #1853009
Related-Bug: #1841481

Change-Id: I260c1fded79a85d4899e94df4d9036a1ee437f02
(cherry picked from commit a8492e8878)
2021-09-30 01:08:03 +00:00
..
sqlalchemy Prevent deletion of a compute node belonging to another host 2021-09-30 01:08:03 +00:00
__init__.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
api.py objects: Remove Agent, AgentList 2020-09-11 14:10:32 +01:00
base.py Use nova.db.api directly 2018-07-10 14:56:27 +00:00
constants.py Move db MAX constants to own file 2018-03-01 11:09:29 +00:00
migration.py cmd: Remove 'nova-manage db null_instance_uuid_scan' 2021-02-02 17:16:12 +00:00