Delete endpoint_group should remove project_endpoint_group at first

Bug #1443765 reported by Dave Chen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Dave Chen
Kilo
Fix Released
Medium
Dolph Mathews

Bug Description

Since the endpoint_group_id of table project_endpoint_group has a foreign key reference with the id of endpoint_group, so if we want to delete endpoint_group we need delete associated project_endpoint_group at first, or else, it will hit follow exceptions:

{"error": {"message": "An unexpected error prevented the server from fulfilling your request: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`keystone`.`project_endpoint_group`, CONSTRAINT `project_endpoint_group_ibfk_1` FOREIGN KEY (`endpoint_group_id`) REFERENCES `endpoint_group` (`id`))') 'DELETE FROM endpoint_group WHERE endpoint_group.id = %s' ('d5c86622fea04c43b0c0e3b540417e1f',) (Disable debug mode to suppress these details.)", "code": 500, "title": "Internal Server Error"}}

Revision history for this message
Dave Chen (wei-d-chen) wrote :

This issue can be addressed easily by adjust current code a little bit.

https://github.com/openstack/keystone/blob/master/keystone/contrib/endpoint_filter/backends/sql.py#L148

Swith the sequence between "_delete_endpoint_group_association_by_endpoint_group" and "session.delete(endpoint_group_ref)" will work.

related BP: ondelete-cascade

Reference: https://blueprints.launchpad.net/keystone/+spec/ondelete-cascade

Changed in keystone:
assignee: nobody → Dave Chen (wei-d-chen)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

Changed in keystone:
status: New → In Progress
Changed in keystone:
importance: Undecided → Medium
Revision history for this message
Dolph Mathews (dolph) wrote :

Does this affect juno?

tags: added: kilo-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/177350

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/173192
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=4b7758c2d633d81411371134e008260baac6c05c
Submitter: Jenkins
Branch: master

commit 4b7758c2d633d81411371134e008260baac6c05c
Author: Dave Chen <email address hidden>
Date: Tue Apr 14 14:55:44 2015 +0800

    Remove project association before removing endpoint group

    Since `project_endpoint_group` has a foreign key reference with `endpoint_group`
    thus, if we want to remove endpoint_group we need to remove associated
    `project_endpoint_group` at first.

    The testcase provided can pass even without code changing only beacuse SQLITE
    didn't enforce foreign key constraint by default, so endpoint group with project
    association can be deleted (needn't delete project association at first)
    successfully.

    Closes-Bug: #1443765
    bp ondelete-cascade

    Change-Id: Id685948373ffb37467f336172a085b91c982cbc7

Changed in keystone:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (stable/kilo)

Reviewed: https://review.openstack.org/177350
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=54400bfd3267caaca7daa27ec35fa963aa557f7e
Submitter: Jenkins
Branch: stable/kilo

commit 54400bfd3267caaca7daa27ec35fa963aa557f7e
Author: Dave Chen <email address hidden>
Date: Tue Apr 14 14:55:44 2015 +0800

    Remove project association before removing endpoint group

    Since `project_endpoint_group` has a foreign key reference with `endpoint_group`
    thus, if we want to remove endpoint_group we need to remove associated
    `project_endpoint_group` at first.

    The testcase provided can pass even without code changing only beacuse SQLITE
    didn't enforce foreign key constraint by default, so endpoint group with project
    association can be deleted (needn't delete project association at first)
    successfully.

    Closes-Bug: #1443765
    bp ondelete-cascade

    Change-Id: Id685948373ffb37467f336172a085b91c982cbc7
    (cherry picked from commit 4b7758c2d633d81411371134e008260baac6c05c)

Changed in keystone:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: liberty-1 → 8.0.0
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.