rootwrap generates "TypeError: Object of type 'ValueError' is not JSON serializable" exception when binary is not found

Bug #1832704 reported by Bernard Cafarelli on 2019-06-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.rootwrap
Undecided
Unassigned

Bug Description

Running rootwrap with commands not found on the system (new dependency and package not added yet for example), we get "TypeError: Object of type 'ValueError' is not JSON serializable" exceptions instead of a more specific exception.

Sample backtrace:
Unserializable message: Traceback (most recent call last):
  File "/usr/lib64/python3.6/multiprocessing/managers.py", line 283, in serve_client
    send(msg)
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/jsonrpc.py", line 128, in send
    s = self.dumps(obj)
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/jsonrpc.py", line 170, in dumps
    return json.dumps(obj, cls=RpcJSONEncoder).encode('utf-8')
  File "/usr/lib64/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/jsonrpc.py", line 43, in default
    return super(RpcJSONEncoder, self).default(o)
  File "/usr/lib64/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'ValueError' is not JSON serializable

Also, when using rootwrap daemon, this seems to cause daemon exit, this is a log observed in neutron (missing "arping" command in new containers):
2019-05-27 09:40:31.717 386982 INFO oslo_rootwrap.client [-] Stopping rootwrap daemon process with pid=422757
2019-05-27 09:40:31.744 386982 DEBUG oslo_rootwrap.client [-] Popen for ['sudo', 'neutron-rootwrap-daemon', '/etc/neutron/rootwrap.conf'] command has been instantiated _initialize /usr/lib/python3.6/site-packages/oslo_rootwrap/client.py:73
2019-05-27 09:40:32.004 386982 INFO oslo_rootwrap.client [-] Spawned new rootwrap daemon process with pid=1007898

Problem may be due to how CommandFilter in Oslo.rootwrap works. See in https://github.com/openstack/oslo.rootwrap/blob/master/oslo_rootwrap/filters.py#L46 - it looks for binary (arping in our case) inside container. If there is no such binary in known paths, it returns None

While this should not happen in production environments, it would be heplful in dev envs (and new OS versions/switch to containers/...) to have a clearer error

Sample downstream issues we hit in neutron when switching to RHEL8:
https://bugzilla.redhat.com/show_bug.cgi?id=1713321
https://bugzilla.redhat.com/show_bug.cgi?id=1714146
https://bugzilla.redhat.com/show_bug.cgi?id=1720134

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers