Getting cluster config fails with encoding error (base64)

Bug #1812816 reported by Yannic Ahrens
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-magnumclient
New
Undecided
Unassigned

Bug Description

When I run try to retrieve the configuration of a Kubernetes cluster spawned by Magnum I receive a TypeError.

''openstack --debug coe cluster config <cluster>'' returns the following traceback:

Traceback (most recent call last):
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/cliff/app.py", line 401, in run_subcommand
 result = cmd.run(parsed_args)
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
 return super(Command, self).run(parsed_args)
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/cliff/command.py", line 184, in run
 return_code = self.take_action(parsed_args) or 0
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/magnumclient/osc/v1/clusters.py", line 353, in take_action
 certs=tls))
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/magnumclient/common/utils.py", line 167, in config_cluster
 force, certs)
  File "/home/yannic/Envs/os-dev/local/lib/python3.6/site-packages/magnumclient/common/utils.py", line 217, in _config_cluster_kubernetes
 'key': base64.b64encode(certs['key']),
  File "/home/yannic/Envs/os-dev/lib/python3.6/base64.py", line 58, in b64encode
 encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'

I figure that replacing the offending statements (e.g. 'key': base64.b64encode(certs['key'])) with the corresponding oslo functionality (oslo_serialization.base64.encode_as_text) resolves the problem.

* Platform: Ubuntu 18.10
* Python 3.6.7
* python-magnumclient: 2.11 (reproducible with upstream master)

Revision history for this message
Spyros Trigazis (strigazi) wrote :

Can you move this to storyboard? I'll make this launchpad account non writable as the magnum one.

this seems to be an issue only in python3.6 I was able to reproduce.

Revision history for this message
Yannic Ahrens (yahrens) wrote :
Revision history for this message
Satish Patel (satish-txt) wrote :

I am getting same issue.

# openstack coe cluster config k8s-cluster --dir ~/my_k8s
a bytes-like object is required, not 'str'

Revision history for this message
Satish Patel (satish-txt) wrote :

Nevermind this resolved my issue

# Remove older version
$ sudo apt-get purge python3-magnumclient

# Install newer version
$ pip3 install python-magnumclient

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.