[Bug 1799746] Re: [SRU] PY3: when uploading file as secret: TypeError: a bytes-like object is required, not 'str'

Launchpad Bug Tracker 1799746 at bugs.launchpad.net
Fri Nov 9 04:18:00 UTC 2018


This bug was fixed in the package barbican - 1:7.0.0-0ubuntu4

---------------
barbican (1:7.0.0-0ubuntu4) disco; urgency=medium

  * d/tests/barbican-shebangs-py3: Update shebang for Python 3.7.

 -- Corey Bryant <corey.bryant at canonical.com>  Wed, 07 Nov 2018 09:22:03
-0500

** Changed in: barbican (Ubuntu)
       Status: Triaged => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to barbican in Ubuntu.
https://bugs.launchpad.net/bugs/1799746

Title:
  [SRU] PY3: when uploading file as secret: TypeError: a bytes-like
  object is required, not 'str'

Status in Ubuntu Cloud Archive:
  Fix Committed
Status in Ubuntu Cloud Archive rocky series:
  Fix Committed
Status in barbican package in Ubuntu:
  Fix Released
Status in barbican source package in Cosmic:
  Fix Committed

Bug description:
  [Impact]
  (clients) ubuntu at beisner-bastion:~/demo$ openstack secret store --name mypubkey2 --file ~/.ssh/id_rsa.pub
  5xx Server error: Internal Server Error: Secret creation failure seen - please contact site administrator.
  Internal Server Error: Secret creation failure seen - please contact site administrator.

  ...

  dpkubuntu at juju-b7ad6b-beisner-0:~$ dpkg -l | grep barbican
  ii  barbican-api                    1:7.0.0-0ubuntu2~cloud0                     all          OpenStack Key Management Service - API Server
  ii  barbican-common                 1:7.0.0-0ubuntu2~cloud0                     all          OpenStack Key Management Service - common files
  ii  barbican-worker                 1:7.0.0-0ubuntu2~cloud0                     all          OpenStack Key Management Service - Worker Node
  ii  python3-barbican                1:7.0.0-0ubuntu2~cloud0                     all          OpenStack Key Management Service - Python 3 files
  ii  python3-barbicanclient          4.6.0-0ubuntu1                              all          OpenStack Key Management API client - Python 3.x
  ubuntu at juju-b7ad6b-beisner-0:~$ apt-cache policy barbican-common
  barbican-common:
    Installed: 1:7.0.0-0ubuntu2~cloud0
    Candidate: 1:7.0.0-0ubuntu2~cloud0
    Version table:
   *** 1:7.0.0-0ubuntu2~cloud0 500
          500 http://ubuntu-cloud.archive.canonical.com/ubuntu bionic-proposed/rocky/main amd64 Packages
          100 /var/lib/dpkg/status
       1:6.0.0-0ubuntu1 500
          500 http://nova.clouds.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

  ...

  [Wed Oct 24 16:28:27.617818 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers Traceback (most recent call last):
  [Wed Oct 24 16:28:27.617822 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/plugin/castellan_secret_store.py", line 86, in store_secret
  [Wed Oct 24 16:28:27.617825 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     opaque_data.OpaqueData(secret_dto.secret)
  [Wed Oct 24 16:28:27.617837 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/castellan/key_manager/vault_key_manager.py", line 319, in store
  [Wed Oct 24 16:28:27.617841 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     return self._store_key_value(key_id, key_value)
  [Wed Oct 24 16:28:27.617844 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/castellan/key_manager/vault_key_manager.py", line 276, in _store_key_value
  [Wed Oct 24 16:28:27.617848 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     'value': binascii.hexlify(value.get_encoded()).decode('utf-8'),
  [Wed Oct 24 16:28:27.617852 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers TypeError: a bytes-like object is required, not 'str'
  [Wed Oct 24 16:28:27.617855 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers
  [Wed Oct 24 16:28:27.617858 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers During handling of the above exception, another exception occurred:
  [Wed Oct 24 16:28:27.617862 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers
  [Wed Oct 24 16:28:27.617865 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers Traceback (most recent call last):
  [Wed Oct 24 16:28:27.617868 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/api/controllers/__init__.py", line 108, in handler
  [Wed Oct 24 16:28:27.617872 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     return fn(inst, *args, **kwargs)
  [Wed Oct 24 16:28:27.617893 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/api/controllers/__init__.py", line 94, in enforcer
  [Wed Oct 24 16:28:27.617897 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     return fn(inst, *args, **kwargs)
  [Wed Oct 24 16:28:27.617900 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/api/controllers/__init__.py", line 156, in content_types_enforcer
  [Wed Oct 24 16:28:27.617903 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     return fn(inst, *args, **kwargs)
  [Wed Oct 24 16:28:27.617906 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/api/controllers/secrets.py", line 445, in on_post
  [Wed Oct 24 16:28:27.617910 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     transport_key_id=data.get('transport_key_id'))
  [Wed Oct 24 16:28:27.617913 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/plugin/resources.py", line 109, in store_secret
  [Wed Oct 24 16:28:27.617917 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     secret_model, project_model)
  [Wed Oct 24 16:28:27.617920 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/plugin/resources.py", line 281, in _store_secret_using_plugin
  [Wed Oct 24 16:28:27.617924 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     secret_metadata = store_plugin.store_secret(secret_dto)
  [Wed Oct 24 16:28:27.617927 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers   File "/usr/lib/python3/dist-packages/barbican/plugin/castellan_secret_store.py", line 92, in store_secret
  [Wed Oct 24 16:28:27.617931 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers     raise ss.SecretGeneralException(e)
  [Wed Oct 24 16:28:27.617938 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers barbican.plugin.interface.secret_store.SecretGeneralException: Problem seen during crypto processing - Reason: a bytes-like object is required, not 'str'
  [Wed Oct 24 16:28:27.617944 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.616 20342 ERROR barbican.api.controllers \x1b[00m
  [Wed Oct 24 16:28:27.617950 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186]
  [Wed Oct 24 16:28:27.619946 2018] [wsgi:error] [pid 20342:tid 140250918270720] [remote 10.5.0.11:46186] 2018-10-24 16:28:27.619 20342 INFO barbican.api.middleware.context [req-983f8362-957b-459c-b21a-d1b2fc64850b 174f3123041f42818318b4ce4d46d755 a5e22ca876884268bf8c2dba92863ecd - 7e87323e783a41a6a9ba9d0763ae3f38 7e87323e783a41a6a9ba9d0763ae3f38] Processed request: 500 Internal Server Error - POST http://10.5.0.11:9311/v1/secrets/\x1b[00m
  10.5.0.11 - - [24/Oct/2018:16:28:27 +0000] "POST /v1/secrets/ HTTP/1.1" 500 376 "-" "openstacksdk/0.18.1 keystoneauth1/3.11.0 python-requests/2.20.0 CPython/3.6.5"

  [Test Case]
  Deploy the rocky release of openstack barbican with python 3 packages. Store a secret in barbican:
      openstack secret store --name mypubkey2 --file ~/.ssh/id_rsa.pub
  Ensure secret is successfully stored.

  [Regression Potential]
  The fix is very minimal and aligns with other code in the affected function. Upstream patch is up for review at: https://review.openstack.org/#/c/613324/.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-archive/+bug/1799746/+subscriptions



More information about the Ubuntu-openstack-bugs mailing list