server group members are not deleted on failed server create overquota

Bug #1569641 reported by Matt Riedemann
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matt Riedemann
Liberty
Fix Released
Medium
Unassigned
Mitaka
Fix Released
Medium
Matt Riedemann

Bug Description

When creating instances in the database in the compute API, if we fail after creating them we attempt to delete the instances from the DB here:

https://github.com/openstack/nova/blob/af7e83fef3bc2c005c581587e9230a4070f8feb9/nova/compute/api.py#L1033

However, if there is a failure it's ignored and we continue and just re-raise the exception.

The instances can fail to delete because of a referential constraint on the block device mappings created here:

https://github.com/openstack/nova/blob/af7e83fef3bc2c005c581587e9230a4070f8feb9/nova/compute/api.py#L1471

So if we don't delete those first, we can't cleanup the instances. You can recreate this by changing CONF.quota_server_group_members=0 and trying to boot a server into a server group.

Tags: api
Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/304929

Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
status: Triaged → In Progress
Revision history for this message
Matt Riedemann (mriedem) wrote :

This can prevent archiving/purging instances so bumping to medium severity and marking it for backport.

Changed in nova:
importance: Low → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/304929
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5674e7646d106751b27d191e3334d9e6ebe9ab1b
Submitter: Jenkins
Branch: master

commit 5674e7646d106751b27d191e3334d9e6ebe9ab1b
Author: Matt Riedemann <email address hidden>
Date: Tue Apr 12 22:09:16 2016 -0400

    Properly clean up BDMs when _provision_instances fails

    _provision_instances calls create_db_entry_for_new_instance
    which creates the instance and block device mappings in the
    database.

    The instance is added to the instances list which is used
    in the global exception block at the bottom of _provision_instances
    to destroy any instances created. A failure that can trigger
    this cleanup attempt after the instance and BDMs are created
    is when checking server group member count fails with OverQuota.

    The problem is that we fail to (soft) delete the block device mappings
    that we created. Since there is a foreign key constraint between
    the block_device_mapping and instances tables in the database,
    when we try to archive (copy soft deleted things to shadow tables
    and then hard-delete them) the deleted instance it will fail on
    a referential constraint error due to the BDM(s) which weren't deleted.

    We can fix this by deleting the BDMs when deleting the instance just
    like we do for other reference tables.

    A functional test is added to demonstrate the failure and fix which
    also has the nice benefit of functionally testing the server group
    member overquota error handling.

    Change-Id: Ida66a93031046bafcf30c95ca232fb6382c2597b
    Closes-Bug: #1569641

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/308491

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/nova 14.0.0.0b1

This issue was fixed in the openstack/nova 14.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/mitaka)

Reviewed: https://review.openstack.org/308491
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=6fce7d3bc9df7157edfc762d2dbd4800d834dd51
Submitter: Jenkins
Branch: stable/mitaka

commit 6fce7d3bc9df7157edfc762d2dbd4800d834dd51
Author: Matt Riedemann <email address hidden>
Date: Tue Apr 12 22:09:16 2016 -0400

    Properly clean up BDMs when _provision_instances fails

    _provision_instances calls create_db_entry_for_new_instance
    which creates the instance and block device mappings in the
    database.

    The instance is added to the instances list which is used
    in the global exception block at the bottom of _provision_instances
    to destroy any instances created. A failure that can trigger
    this cleanup attempt after the instance and BDMs are created
    is when checking server group member count fails with OverQuota.

    The problem is that we fail to (soft) delete the block device mappings
    that we created. Since there is a foreign key constraint between
    the block_device_mapping and instances tables in the database,
    when we try to archive (copy soft deleted things to shadow tables
    and then hard-delete them) the deleted instance it will fail on
    a referential constraint error due to the BDM(s) which weren't deleted.

    We can fix this by deleting the BDMs when deleting the instance just
    like we do for other reference tables.

    A functional test is added to demonstrate the failure and fix which
    also has the nice benefit of functionally testing the server group
    member overquota error handling.

    Change-Id: Ida66a93031046bafcf30c95ca232fb6382c2597b
    Closes-Bug: #1569641
    (cherry picked from commit 5674e7646d106751b27d191e3334d9e6ebe9ab1b)

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 13.1.1

This issue was fixed in the openstack/nova 13.1.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.