Bug 881568

Summary: [ALL LANG][SAM Web GUI] Unexpected error: Couldn't find Organization with ID=1 [WHERE "organizations"."task_id" IS NULL] occurred when failed deletion for the default org 'ACME_Corporation'.
Product: Subscription Asset Manager Reporter: Lijun Li <lijli>
Component: katelloAssignee: Katello Bug Bin <katello-bugs>
Status: NEW --- QA Contact: sthirugn <sthirugn>
Severity: high Docs Contact:
Priority: high    
Version: 1.3CC: athomas, bkearney, cwelton, lzap, qe-i18n-bugs, sthirugn, tomckay
Target Milestone: rcKeywords: i18n
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 882311 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 1001609    
Bug Blocks: 971511, 882311    
Attachments:
Description Flags
Unexpected error: Couldn't find Organization with ID=1
none
kateloo-debug tarball
none
Delete ACME_Corporation
none
Error on trying to add ACME_Corporation after it is deleted none

Comment 1 Lijun Li 2012-11-29 01:19:43 EST
*** Bug 881569 has been marked as a duplicate of this bug. ***
Comment 2 Lijun Li 2012-11-29 01:23:51 EST
Created attachment 654004 [details]
Unexpected error: Couldn't find Organization with ID=1
Comment 3 Tom McKay 2012-12-12 10:15:39 EST
Moving out as not a blocker. Could be result of slow-running background tasks during org deletion. Waiting a few minutes, the error message did not reappear.
Comment 4 Tom McKay 2012-12-12 10:16:02 EST
Clearing needinfo
Comment 5 Lukas Zapletal 2012-12-13 12:06:09 EST
@Marek - taking as I am alrady working on the same one:

https://bugzilla.redhat.com/show_bug.cgi?id=885261
Comment 7 Lukas Zapletal 2012-12-19 10:33:23 EST
So I can confirm your katello-jobs service had not to be running or you just did it too fast. Sometimes org deletion can be put on hold for some time and you need to wait - the error will disappear once organization is deleted.

Current organization deletion code is not good and I hesitate to implement a workaround for it as we will refactor our orchestration shortly. This looks like a Release Note for both SE and SAM releases just to wait until org is deleted.
Comment 9 Lijun Li 2012-12-19 22:06:45 EST
Created attachment 666495 [details]
kateloo-debug tarball
Comment 10 Lukas Zapletal 2013-01-11 12:20:26 EST
The patch was finally merged upstream, please test accordingly as it completely change the way how we dealing with orgs being deleted: https://github.com/Katello/katello/pull/1358
Comment 11 Bryan Kearney 2013-06-06 16:50:31 EDT
Moving all POST / MODIFIED bugs to ON_QA due to the new builds.
Comment 12 Tazim Kolhar 2013-08-07 05:00:39 EDT
Created attachment 783747 [details]
Delete ACME_Corporation

# rpm -qa | grep katello
katello-selinux-1.4.4-2.el6sat.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-certs-tools-1.4.2-2.el6sat.noarch
katello-common-1.4.3-5.el6sam_splice.noarch
katello-configure-1.4.4-2.el6sat.noarch
katello-cli-common-1.4.3-4.el6sat.noarch
katello-glue-elasticsearch-1.4.3-5.el6sam_splice.noarch
katello-headpin-all-1.4.3-5.el6sam_splice.noarch
katello-cli-1.4.3-4.el6sat.noarch
katello-glue-candlepin-1.4.3-5.el6sam_splice.noarch
signo-katello-0.0.10-2.el6sat.noarch
katello-headpin-1.4.3-5.el6sam_splice.noarch

# headpin -u admin -p admin org list
--------------------------------------------------------------------------------
                               Organization List

ID Name    Label   Description 
--------------------------------------------------------------------------------
3  Red Hat Red_Hat             
2  test    test             

Here,if you see a newly created org has got the ID -2,3
Comment 13 Bryan Kearney 2013-08-14 16:18:44 EDT
This code appears to be to in the delivery.
Comment 14 sthirugn@redhat.com 2013-08-16 16:29:28 EDT
Failed.  Attempted to delete ACME_Corporation and got a user message that the org is scheduled to be deleted.

I waited for few minkutes and attempted to create ACME_Corporation again, but it wouldn't let me do it. (UI Screenshot attached)

Version tested:
* candlepin-0.8.20-1.el6sam.noarch
* candlepin-cert-consumer-cloud-qe-21.idm.lab.bos.redhat.com-1.0-1.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.20-1.el6sam.noarch
* candlepin-tomcat6-0.8.20-1.el6sam.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.3-7.el6sat.noarch
* katello-cli-common-1.4.3-7.el6sat.noarch
* katello-common-1.4.3-8.el6sam_splice.noarch
* katello-configure-1.4.4-2.el6sat.noarch
* katello-glue-candlepin-1.4.3-8.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-8.el6sam_splice.noarch
* katello-headpin-1.4.3-8.el6sam_splice.noarch
* katello-headpin-all-1.4.3-8.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.32-1.el6sam.noarch
* thumbslug-selinux-0.0.32-1.el6sam.noarch
Comment 15 sthirugn@redhat.com 2013-08-16 16:30:14 EDT
Created attachment 787455 [details]
Error on trying to add ACME_Corporation after it is deleted
Comment 17 Lukas Zapletal 2013-08-20 04:15:52 EDT
My patch can be considered as verified, because it works. This is different error introduced when foreign keys were implemented. Open a bug with this topic:

    Foreign key is preventing an org from being deleted.

The error message is:

2013-08-16T14:04:01-0400: [Worker(delayed_job host:cloud-qe-21.idm.lab.bos.redhat.com pid:7267)] 1 jobs processed at 8.4682 j/s, 1 failed ...
2013-08-16T15:57:10-0400: [Worker(delayed_job host:cloud-qe-21.idm.lab.bos.redhat.com pid:7267)] OrganizationDestroyer#run failed with ActiveRecord::                  +InvalidForeignKey: PGError: ERROR:  update or delete on table "organizations" violates foreign key constraint "notices_organization_id_fk" on table "notices"
DETAIL:  Key (id)=(1) is still referenced from table "notices".
: COMMIT - 0 failed attempts
2013-08-16T15:57:10-0400: [Worker(delayed_job host:cloud-qe-21.idm.lab.bos.redhat.com pid:7267)] PERMANENTLY removing OrganizationDestroyer#run because of 1           +consecutive failures.
PGError: ERROR:  update or delete on table "organizations" violates foreign key constraint "notices_organization_id_fk" on table "notices"
DETAIL:  Key (id)=(1) is still referenced from table "notices".
: COMMIT
Comment 18 sthirugn@redhat.com 2013-08-28 10:53:43 EDT
An other bug is created https://bugzilla.redhat.com/show_bug.cgi?id=1001609 to track the foreign key error.
Comment 19 Lukas Zapletal 2014-03-12 06:22:09 EDT
This should be re-investigated, not sure if this is relevant due to dynflow change.