Comment 14 for bug 1839560

Reviewed: https://review.opendev.org/676514
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9ce94844fa6a43368445182bb086876874256197
Submitter: Zuul
Branch: stable/rocky

commit 9ce94844fa6a43368445182bb086876874256197
Author: Matt Riedemann <email address hidden>
Date: Mon Aug 12 14:39:16 2019 -0400

    Restore soft-deleted compute node with same uuid

    There is a unique index on the compute_nodes.uuid column which
    means we can't have more than one compute_nodes record in the
    same DB with the same UUID even if one is soft deleted because
    the deleted column is not part of that unique index constraint.

    This is a problem with ironic nodes where the node is 1:1 with
    the compute node record, and when a node is undergoing maintenance
    the driver doesn't return it from get_available_nodes() so the
    ComputeManager.update_available_resource periodic task (soft)
    deletes the compute node record, but when the node is no longer
    under maintenance in ironic and the driver reports it, the
    ResourceTracker._init_compute_node code will fail to create the
    ComputeNode record again because of the duplicate uuid.

    This change handles the DBDuplicateEntry error in compute_node_create
    by finding the soft-deleted compute node with the same uuid and
    simply updating it to no longer be (soft) deleted.

    Closes-Bug: #1839560

    Change-Id: Iafba419fe86446ffe636721f523fb619f8f787b3
    (cherry picked from commit 8b007266f438ec0a5a797d05731cce6f2b155f4c)
    (cherry picked from commit 1b021665281b74c865d3571fc90772b52d70e467)