Bug 980333 - Met Mongoid::Errors::DeleteRestriction when deleting a domain with app by oo-admin-ctl-domain
Summary: Met Mongoid::Errors::DeleteRestriction when deleting a domain with app by oo-...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Pod
Version: 2.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Ravi Sankar
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-02 06:02 UTC by chunchen
Modified: 2016-09-30 02:15 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-07-22 15:19:31 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description chunchen 2013-07-02 06:02:03 UTC
Description of problem:
If deleting a domain with app by oo-admin-ctl-domain, will meet Mongoid::Errors::DeleteRestriction errors.

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

How reproducible:
always

Steps to Reproduce:
1. Setup an account and create a domain named "cdm"
rhc setup --server ec2-54-242-245-159.compute-1.amazonaws.com -l chunchen
2. Create an app
rhc app create cdiy diy-0.1 --no-git
3. SSH into the instance and delete this domain by oo-admin-ctl-domain
oo-admin-ctl-domain -l chunchen -c delete -n cdm

Actual results:
/opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/cascading/restrict.rb:32:in `cascade':  (Mongoid::Errors::DeleteRestriction)
Problem:
  Cannot delete Domain because of dependent 'applications'.
Summary:
  When defining 'applications' with a :dependent => :restrict, Mongoid will raise an error when attempting to delete the Domain when the child 'applications' still has documents in it.
Resolution:
  Don't attempt to delete the parent Domain when it has children, or change the dependent option on the relation.
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/cascading.rb:32:in `block in cascade!'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/cascading.rb:28:in `each'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/cascading.rb:28:in `cascade!'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/persistence/deletion.rb:22:in `prepare'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/persistence/operations/remove.rb:26:in `persist'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/persistence.rb:62:in `remove'
	from /usr/sbin/oo-admin-ctl-domain:257:in `<main>'


Expected results:
Should only return a short error messages like "Your domain contains applications. Delete applications first."

Additional info:

Comment 1 Ravi Sankar 2013-07-05 22:45:18 UTC
Fixed in https://github.com/openshift/origin-server/pull/2994

Comment 2 openshift-github-bot 2013-07-06 00:00:15 UTC
Commits pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/258dcb2d73dea5b3edc18e8bfb7442b2164212b0
Bug 980333 - Add missing 'exit 1' in oo-admin-ctl-domain

https://github.com/openshift/origin-server/commit/179cbade56db0d92ab6f7eac50a75a0e6cf3ca62
Merge pull request #2994 from pravisankar/dev/ravi/bug980333

Merged by openshift-bot

Comment 3 chunchen 2013-07-08 03:32:55 UTC
It's fixed, checked on devenv_3456, please help to change status to ON_QA, then i will modify to VERIFIED. Please refer to the following results:

1. Setup an account and create a domain named "cdm"
2. Create an app
3. SSH into the instance and delete this domain by oo-admin-ctl-domain
oo-admin-ctl-domain -l chunchen -c delete -n cdm

Actual results:
User still has applications. Delete them first.


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