Bug 1198914 - orphan access policy rows
Summary: orphan access policy rows
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: general
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: 21.0
Assignee: matt jia
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-05 05:25 UTC by Dan Callaghan
Modified: 2018-02-06 00:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-08-26 06:17:22 UTC
Embargoed:


Attachments (Terms of Use)

Description Dan Callaghan 2015-03-05 05:25:41 UTC
Description of problem:
system_access_policy.system_id is NULLable, and there are no suitable cascade rules, so it is possible to have orphaned systemd_access_policy rows (not belonging to any system).

Most likely they are left behind when deleting a system with bkr system-delete, need to confirm.

Version-Release number of selected component (if applicable):
19.2

Comment 2 matt jia 2015-05-06 00:31:20 UTC
The system_id is dropped in 

http://gerrit.beaker-project.org/#/c/4011/

so I donnot think this is an issue any more.

Comment 3 Dan Callaghan 2015-05-06 05:30:40 UTC
(In reply to matt jia from comment #2)

The orphans still exist, just the query to find them is a bit more complicated.

select * from system_access_policy where not exists (select 1 from system where custom_access_policy_id = system_access_policy.id) and not exists (select 1 from system_pool where access_policy_id = system_access_policy.id);

Comment 7 matt jia 2015-05-19 03:58:46 UTC
On Gerrit:

  http://gerrit.beaker-project.org/#/c/4217/

Comment 9 matt jia 2015-06-16 00:22:05 UTC
Verified steps:

1. create an system

2. delete this system with bkr system-delete

3. check if the associated record in system_access_policy is deleted

Comment 13 Dan Callaghan 2015-08-11 01:45:10 UTC
The migration for deleting old policies is not quite correct, it doesn't work when the policies actually exist with rules in them.

sqlalchemy.exc.IntegrityError: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`beaker`.`system_access_policy_rule`, CONSTRAINT `system_access_policy_rule_policy_id_fk` FOREIGN KEY (`policy_id`) REFERENCES `system_access_policy` (`id`))') '\n        DELETE FROM system_access_policy WHERE\n        NOT EXISTS (SELECT 1 FROM system WHERE custom_access_policy_id =\n        system_access_policy.id) AND NOT EXISTS(SELECT 1 FROM system_pool\n        WHERE access_policy_id = system_access_policy.id)\n        ' ()

Comment 14 Dan Callaghan 2015-08-11 02:30:53 UTC
http://gerrit.beaker-project.org/4338

Comment 17 Dan Callaghan 2015-08-26 06:17:22 UTC
Beaker 21.0 has been released.


Note You need to log in before you can comment on or make changes to this bug.