Bug 1402357 - [RFE] validate arguments in vdsm-client
Summary: [RFE] validate arguments in vdsm-client
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: vdsm
Classification: oVirt
Component: Core
Version: 4.18.0
Hardware: Unspecified
OS: Unspecified
low
low vote
Target Milestone: ---
: ---
Assignee: Irit Goihman
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-07 10:41 UTC by Nir Soffer
Modified: 2022-06-27 08:07 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-03-02 10:19:38 UTC
oVirt Team: Infra
sbonazzo: ovirt-4.3-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHV-46635 0 None None None 2022-06-27 08:07:56 UTC
oVirt gerrit 84686 0 master ABANDONED vdsm api: provide an informative warning instead of exception 2018-05-06 01:58:45 UTC

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.


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