Bug 1370399

Summary: The message is no meaningful when delete a nonexistent system via CLI
Product: [Community] Beaker Reporter: Hui Wang <huiwang>
Component: command lineAssignee: Hui Wang <huiwang>
Status: CLOSED CURRENTRELEASE QA Contact: Dan Callaghan <dcallagh>
Severity: low Docs Contact:
Priority: low    
Version: 23CC: dcallagh, mjia, rjoost
Target Milestone: 24.0Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-21 18:50:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Hui Wang 2016-08-26 08:22:35 UTC
Description of problem:
When I delete a nonexistent system, it will give no meaningful message: NoResultFound: No row was found for one()

Version-Release number of selected component (if applicable):
Beaker 24.0.git.37.717f87f 

How reproducible:


Steps to Reproduce:
1.In client to delete a nonexistent system
$bkr system-delete $nonexistent_system
2.
3.

Actual results:
XML-RPC fault: <class 'sqlalchemy.orm.exc.NoResultFound'>:No row was found for one()


Expected results:
Give the meaningful message, like:
Sorry, there is no system named $nonexistent_system. Pls add it first.

Additional info:

bkr.server.xmlrpccontroller ERROR Error handling XML-RPC method
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/bkr/server/xmlrpccontroller.py", line 53, in RPC2
response = self.process_rpc(method,params)
File "/usr/lib/python2.6/site-packages/bkr/server/xmlrpccontroller.py", line 42, in process_rpc
response = obj(*params)
File "<string>", line 3, in delete
File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 356, in expose
*args, **kw)
File "<generated code>", line 0, in _expose
File "/usr/lib/python2.6/site-packages/peak/rules/core.py", line 153, in __call__
return self.body(*args, **kw)
File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 390, in <lambda>
fragment, options, args, kw)))
File "/usr/lib/python2.6/site-packages/turbogears/controllers.py", line 425, in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "/usr/lib/python2.6/site-packages/turbogears/errorhandling.py", line 77, in try_call
return func(self, *args, **kw)
File "<string>", line 2, in delete
File "/usr/lib/python2.6/site-packages/bkr/server/identity.py", line 288, in require
Areturn func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/bkr/server/systems.py", line 92, in delete
system = System.by_fqdn(fqdn, identity.current.user)
File "/usr/lib/python2.6/site-packages/bkr/server/model/inventory.py", line 740, in by_fqdn
return System.all(user).filter(System.fqdn == fqdn).one()
File "/usr/lib64/python2.6/site-packages/sqlalchemy/orm/query.py", line 2329, in one
raise orm_exc.NoResultFound("No row was found for one()")
NoResultFound: No row was found for one()

Comment 1 Hui Wang 2016-08-26 08:46:56 UTC
tests patch: https://gerrit.beaker-project.org/#/c/5158/

Comment 2 Roman Joost 2016-08-30 00:04:07 UTC
Sorry - my mistake of taken the patch as the fix.

Comment 3 Hui Wang 2016-09-01 08:09:48 UTC
(In reply to Roman Joost from comment #2)
> Sorry - my mistake of taken the patch as the fix.

Hi Roman, 
I try to fix this issue. So you can assign this bug to me.

BR,
Sophia Wang

Comment 4 Hui Wang 2016-09-02 05:39:29 UTC
fix patch: https://gerrit.beaker-project.org/#/c/5158/

Comment 6 Dan Callaghan 2016-09-06 01:02:12 UTC
Verified:

$ bkr system-delete idonotexist
XML-RPC fault: <class 'bkr.server.bexceptions.DatabaseLookupError'>:System idonotexist does not exist

We could also consider adding some handling for DatabaseLookupError in xmlrpccontroller.py to make this fault message slightly cleaner -- but it's not a big deal. I would rather just port that bkr command to use the JSON interface instead.

Comment 7 Dan Callaghan 2017-02-21 18:50:53 UTC
Beaker 24.0 has been released.