Closed GMW99 closed 3 years ago
So Python-Cephlibs used to require that the data be passed as a string as shown here
def write(self, key, data, offset=0):
"""
Write data to an object synchronously
:param key: name of the object
:type key: str
:param data: data to write
:type data: str
:param offset: byte offset in the object to begin writing at
:type offset: int
:raises: :class:`TypeError`
:raises: :class:`LogicError`
:returns: int - 0 on success
"""
self.require_ioctx_open()
if not isinstance(key, str):
raise TypeError('key must be a string')
if not isinstance(data, str):
raise TypeError('data must be a string')
Whereas rados python3 requires the data as bytes
def write(self, key: str, data: bytes, offset: int = 0):
"""
Write data to an object synchronously
:param key: name of the object
:param data: data to write
:param offset: byte offset in the object to begin writing at
:raises: :class:`TypeError`
:raises: :class:`LogicError`
:returns: int - 0 on success
"""
self.require_ioctx_open()
key_raw = cstr(key, 'key')
cdef:
char *_key = key_raw
char *_data = data
size_t length = len(data)
uint64_t _offset = offset
with nogil:
ret = rados_write(self.io, _key, _data, length, _offset)
if ret == 0:
return ret
elif ret < 0:
raise make_ex(ret, "Ioctx.write(%s): failed to write %s"
% (self.name, key))
else:
raise LogicError("Ioctx.write(%s): rados_write \
returned %d, but should return zero on success." % (self.name, ret))
Therefore the change to update is to convert the data to bytes.
When using python3-rados all tests fail on the test_dataset.py
python3 test_dataset.py --engine cpu --backend ceph --connection dosna --connection-options conffile=ceph.conf
When run in python2 all tests pass. The errors are as follows:These errors suggest that rados has changed how data is passed as is suggesting it requires a byte format.