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
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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/", line 283, in serve_client
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/", line 128, in send
    s = self.dumps(obj)
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/", line 170, in dumps
    return json.dumps(obj, cls=RpcJSONEncoder).encode('utf-8')
  File "/usr/lib64/python3.6/json/", line 238, in dumps
  File "/usr/lib64/python3.6/json/", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.6/json/", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.6/site-packages/oslo_rootwrap/", line 43, in default
    return super(RpcJSONEncoder, self).default(o)
  File "/usr/lib64/python3.6/json/", line 180, in default
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/
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 - 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:

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

Other bug subscribers