Bug 1402357

Summary: [RFE] validate arguments in vdsm-client
Product: [oVirt] vdsm Reporter: Nir Soffer <nsoffer>
Component: CoreAssignee: Irit Goihman <igoihman>
Status: CLOSED DEFERRED QA Contact: Pavel Stehlik <pstehlik>
Severity: low Docs Contact:
Priority: low    
Version: 4.18.0CC: bugs, mperina, pkliczew, ybronhei
Target Milestone: ---Keywords: FutureFeature
Target Release: ---Flags: sbonazzo: ovirt-4.3-
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: 2018-03-02 10:19:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Nir Soffer 2016-12-07 10:41:37 UTC
Description of problem:

When a user call vdsm with non-existing api, vdsm log an error with a traceback in
vdsm log:

2016-12-07 10:03:51,073 ERROR (jsonrpc/0) [jsonrpc.JsonRpcServer] Internal server error (__init__:552)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/yajsonrpc/__init__.py", line 547, in _handle_request
    res = method(**params)
  File "/usr/lib/python2.7/site-packages/vdsm/rpc/Bridge.py", line 184, in _dynamicMethod
    api = self._get_api_instance(className, argobj)
  File "/usr/lib/python2.7/site-packages/vdsm/rpc/Bridge.py", line 166, in _get_api_instance
    apiObj = getattr(API, className)
AttributeError: 'module' object has no attribute 'Lease'

This a user error, not vdsm error, so we should not log an error but a warning.

Additionally, the warning should be helpful to the user, not expose implementation
details.

The warning should be something like:

    No such api 'Lease.create'

Or:

    No such namespace 'Lease'

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

How reproducible:
Always

Steps to Reproduce:
1. Call non existing api

    contrib/jsonrpc MissingNamesapce noSuchMethod

Comment 1 Nir Soffer 2016-12-07 10:43:51 UTC
Same issue when calling with incorrect number of arguments:

2016-12-07 10:08:40,902 ERROR (jsonrpc/2) [jsonrpc.JsonRpcServer] Internal server error (__init__:552)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/yajsonrpc/__init__.py", line 547, in _handle_request
    res = method(**params)
  File "/usr/lib/python2.7/site-packages/vdsm/rpc/Bridge.py", line 184, in _dynamicMethod
    api = self._get_api_instance(className, argobj)
  File "/usr/lib/python2.7/site-packages/vdsm/rpc/Bridge.py", line 169, in _get_api_instance
    return apiObj(*ctorArgs)
TypeError: __init__() takes exactly 2 arguments (1 given)

Should log a warning about incorrect number of arguments.

Comment 2 Irit Goihman 2018-01-09 12:25:35 UTC
The user can't call a non-existing API anymore since the called are made via vdsm python client or vdsm-client.
The client holds a list of supported namespaces and methods and will raise an exception if the user tries to run a non existing command.
We don't have a check of number of arguments and I think it should added to the client verification rather than changing the code in Bridge.py.
I don't consider printing the exception in the log as a real issue since vdsm-client is a debugging tool and users are not using it regularly.

Comment 3 Yaniv Kaul 2018-02-28 16:27:35 UTC
I don't see us investing in this in 4.3. Close or defer to 4.4 please.