```
[-] Creating image backup, image_id: 27ac514a-2c60-4f37-9e48-500d78a7946f.
[-] Protecting image (id: 27ac514a-2c60-4f37-9e48-500d78a7946f) to bank failed.: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 0: invalid continuation byte
Traceback (most recent call last):
.py", line 199, in _create_backup
self._data_block_size_bytes
File "/var/lib/kolla/venv/lib/python3.6/site-packages/karbor/services/protection/protection_plugins/utils.py", line 37, in backup_image_to_bank
bank_section.update_object("data_" + str(chunks_num), data)
File "/var/lib/kolla/venv/lib/python3.6/site-packages/karbor/services/protection/bank_plugin.py", line 241, in update_object
context=context
File "/var/lib/kolla/venv/lib/python3.6/site-packages/karbor/services/protection/bank_plugin.py", line 120, in update_object
context=context)
File "/var/lib/kolla/venv/lib/python3.6/site-packages/karbor/services/protection/bank_plugins/swift_bank_plugin.py", line 118, in update_object
value = jsonutils.dumps(value)
File "/var/lib/kolla/venv/lib/python3.6/site-packages/oslo_serialization/jsonutils.py", line 201, in dumps
return json.dumps(obj, default=default, **kwargs)
File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/var/lib/kolla/venv/lib/python3.6/site-packages/oslo_serialization/jsonutils.py", line 106, in to_primitive
return value.decode(encoding=encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 0: invalid continuation byte
```
It seems to be caused by the migration from Python2 to Python3.
In the errors above, we can see that it tried to decode some binary data (one chunk of image fetched from glance). The binary data is bytes type in Python3, but it's not unicode data.
In "karbor/services/protection/bank_plugins/swift_bank_plugin.py", there is a function update_object.
After upgrade to Ussuri version, we got an error:
``` 2c60-4f37- 9e48-500d78a794 6f. 2c60-4f37- 9e48-500d78a794 6f) to bank failed.: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xeb in position 0: invalid continuation byte _data_block_ size_bytes kolla/venv/ lib/python3. 6/site- packages/ karbor/ services/ protection/ protection_ plugins/ utils.py" , line 37, in backup_ image_to_ bank section. update_ object( "data_" + str(chunks_num), data) kolla/venv/ lib/python3. 6/site- packages/ karbor/ services/ protection/ bank_plugin. py", line 241, in update_object context kolla/venv/ lib/python3. 6/site- packages/ karbor/ services/ protection/ bank_plugin. py", line 120, in update_object context) kolla/venv/ lib/python3. 6/site- packages/ karbor/ services/ protection/ bank_plugins/ swift_bank_ plugin. py", line 118, in update_object dumps(value) kolla/venv/ lib/python3. 6/site- packages/ oslo_serializat ion/jsonutils. py", line 201, in dumps python3. 6/json/ __init_ _.py", line 238, in dumps kw).encode( obj) python3. 6/json/ encoder. py", line 199, in encode python3. 6/json/ encoder. py", line 257, in iterencode kolla/venv/ lib/python3. 6/site- packages/ oslo_serializat ion/jsonutils. py", line 106, in to_primitive encoding= encoding) rror: 'utf-8' codec can't decode byte 0xeb in position 0: invalid continuation byte
[-] Creating image backup, image_id: 27ac514a-
[-] Protecting image (id: 27ac514a-
Traceback (most recent call last):
.py", line 199, in _create_backup
self.
File "/var/lib/
bank_
File "/var/lib/
context=
File "/var/lib/
context=
File "/var/lib/
value = jsonutils.
File "/var/lib/
return json.dumps(obj, default=default, **kwargs)
File "/usr/lib/
**
File "/usr/lib/
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/
return _iterencode(o, 0)
File "/var/lib/
return value.decode(
UnicodeDecodeE
```
It seems to be caused by the migration from Python2 to Python3.
In the errors above, we can see that it tried to decode some binary data (one chunk of image fetched from glance). The binary data is bytes type in Python3, but it's not unicode data.
In "karbor/ services/ protection/ bank_plugins/ swift_bank_ plugin. py", there is a function update_object.
https:/ /github. com/openstack/ karbor/ blob/0764f5dab1 2034efdc41d35cc d627f2a6618c459 /karbor/ services/ protection/ bank_plugins/ swift_bank_ plugin. py#L117
```
value = jsonutils. dumps(value)
serialized = True
self. _put_object( container= self.bank_ object_ container,
obj=key,
contents= value,
headers= {
'x- object- meta-serialized ': str(serialized)
}) Failed as err:
LOG. error(" update object failed, err: %s.", err) BankUpdateObjec tFailed( reason= err, key=key)
def update_object(self, key, value, context=None):
serialized = False
try:
if not isinstance(value, str):
except SwiftConnection
raise exception.
```
We can see that it tests if "value" is "str" type. If not, it calls jsonutils.dumps to serialize it.
In Python2, binary data is str type. But in Python3, it's "bytes" type, not "str". So in Python3, we can't test if an object is binary in this way.