BarbicanSecrets.create_symmetric_and_delete: TypeError: Object of type 'bytes' is not JSON serializable

Bug #1819285 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Rally
Fix Released
Undecided
Unassigned

Bug Description

rally-openstack commit hash: 992419828496abe48a6dedc71416ea8bebb87e77

With python3 create_symmetric_and_delete scenario fails in the code path of rally_openstack/services/key_manager/barbican.py:create_secret when a field of type 'binary' is attempted to be encoded as JSON:

test scenario BarbicanSecrets.create_symmetric_and_delete
args position 0
args values:
{
  "args": {
    "payload": "rally_data",
    "algorithm": "aes",
    "bit_length": 256,
    "mode": "cbc"
  },
  "runner": {
    "times": 2,
    "concurrency": 1
  },
  "contexts": {
    "users": {
      "tenants": 1,
      "users_per_tenant": 1
    }
  },
  "sla": {
    "failure_rate": {
      "max": 0
    }
  },
  "hooks": []
}

--------------------------------------------------------------------------------
Task 5a46c709-2faf-4ad6-8f58-751fdb9e4f27 has 2 error(s)
--------------------------------------------------------------------------------

TypeError: Object of type 'bytes' is not JSON serializable

Traceback (most recent call last):
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/runner.py", line 71, in _run_scenario_once
    getattr(scenario_inst, method_name)(**scenario_kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally_openstack/scenarios/barbican/secrets.py", line 127, in run
    payload_content_encoding="base64")
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/service.py", line 116, in wrapper
    return func(instance, *args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/atomic.py", line 91, in func_atomic_actions
    f = func(self, *args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally_openstack/services/key_manager/barbican.py", line 52, in create_secret
    val.store()
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/v1/secrets.py", line 44, in wrapper
    return func(self, *args)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/v1/secrets.py", line 340, in store
    response = self._api.post(self._entity, json=secret_dict)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/client.py", line 75, in post
    return super(_HTTPClient, self).post(path, *args, **kwargs).json()
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 357, in post
    return self.request(url, 'POST', **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/client.py", line 62, in request
    resp = super(_HTTPClient, self).request(*args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 213, in request
    return self.session.request(url, method, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/session.py", line 764, in request
    kwargs['data'] = self._json.encode(json)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/session.py", line 112, in default
    return super(_JSONEncoder, self).default(o)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable

--------------------------------------------------------------------------------
TypeError: Object of type 'bytes' is not JSON serializable

Traceback (most recent call last):
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/runner.py", line 71, in _run_scenario_once
    getattr(scenario_inst, method_name)(**scenario_kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally_openstack/scenarios/barbican/secrets.py", line 127, in run
    payload_content_encoding="base64")
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/service.py", line 116, in wrapper
    return func(instance, *args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally/task/atomic.py", line 91, in func_atomic_actions
    f = func(self, *args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/rally_openstack/services/key_manager/barbican.py", line 52, in create_secret
    val.store()
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/v1/secrets.py", line 44, in wrapper
    return func(self, *args)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/v1/secrets.py", line 340, in store
    response = self._api.post(self._entity, json=secret_dict)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/client.py", line 75, in post
    return super(_HTTPClient, self).post(path, *args, **kwargs).json()
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 357, in post
    return self.request(url, 'POST', **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/barbicanclient/client.py", line 62, in request
    resp = super(_HTTPClient, self).request(*args, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 213, in request
    return self.session.request(url, method, **kwargs)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/session.py", line 764, in request
    kwargs['data'] = self._json.encode(json)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/snap/fcbtest/x12/lib/python3.6/site-packages/keystoneauth1/session.py", line 112, in default
    return super(_JSONEncoder, self).default(o)
  File "/snap/fcbtest/x12/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable

--------------------------------------------------------------------------------
+---------------------------------------------------------------------------------------------------------------------------+
| Response Times (sec) |
+------------------------+-----------+--------------+--------------+--------------+-----------+-----------+---------+-------+
| Action | Min (sec) | Median (sec) | 90%ile (sec) | 95%ile (sec) | Max (sec) | Avg (sec) | Success | Count |
+------------------------+-----------+--------------+--------------+--------------+-----------+-----------+---------+-------+
| barbican.create_secret | 0.431 | 0.465 | 0.492 | 0.496 | 0.499 | 0.465 | 0.0% | 2 |
| total | 0.434 | 0.472 | 0.502 | 0.506 | 0.51 | 0.472 | 0.0% | 2 |
| -> duration | 0.434 | 0.472 | 0.502 | 0.506 | 0.51 | 0.472 | 0.0% | 2 |
| -> idle_duration | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0% | 2 |
+------------------------+-----------+--------------+--------------+--------------+-----------+-----------+---------+-------+

Load duration: 0.953127
Full duration: 8.319369

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to rally-openstack (master)

Reviewed: https://review.opendev.org/717759
Committed: https://git.openstack.org/cgit/openstack/rally-openstack/commit/?id=6363976229966b726d1fb05f75e1b37a61d684f4
Submitter: Zuul
Branch: master

commit 6363976229966b726d1fb05f75e1b37a61d684f4
Author: Andrey Kurilin <email address hidden>
Date: Mon Apr 6 16:50:53 2020 +0300

    [py3] Fix BarbicanSecrets.create_symmetric_and_delete

    Change-Id: I81709ae6ec87cba194945cd38859e0f54a7482f7
    Closes-Bug: #1819285

Changed in rally:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.