ceph: fix write emulation
Ceph never raises ObjectNotFound on write. Change-Id: Ida84fcbcb9fbd75b90eb11b57f3db271c1425102
This commit is contained in:
parent
f1f81c552b
commit
fc3838243a
@ -415,12 +415,6 @@ class AggregatedTimeSerie(TimeSerie):
|
||||
return int((self.first.value - split) // (self.sampling * 10e8)
|
||||
* self.SERIAL_LEN)
|
||||
|
||||
@staticmethod
|
||||
def padding(offset):
|
||||
offset = offset // AggregatedTimeSerie.SERIAL_LEN
|
||||
pad = [False] * offset * 2
|
||||
return struct.pack('<' + '?d' * offset, *pad)
|
||||
|
||||
def _truncate(self, quick=False):
|
||||
"""Truncate the timeserie."""
|
||||
if self.max_size is not None:
|
||||
|
@ -257,12 +257,7 @@ class CephStorage(_carbonara.CarbonaraBasedStorage):
|
||||
granularity, data, offset=0, version=3):
|
||||
name = self._get_object_name(metric, timestamp_key,
|
||||
aggregation, granularity, version)
|
||||
try:
|
||||
self.ioctx.write(name, data, offset=offset)
|
||||
except rados.ObjectNotFound:
|
||||
# first time writing data
|
||||
self.ioctx.write_full(
|
||||
name, carbonara.AggregatedTimeSerie.padding(offset) + data)
|
||||
self.ioctx.set_xattr("gnocchi_%s_container" % metric.id, name, "")
|
||||
|
||||
def _delete_metric_measures(self, metric, timestamp_key, aggregation,
|
||||
|
@ -140,11 +140,11 @@ class FakeRadosModule(object):
|
||||
self._validate_key(key)
|
||||
try:
|
||||
current = self.kvs[key]
|
||||
except KeyError:
|
||||
current = b""
|
||||
if len(current) < offset:
|
||||
current += b'\x00' * (offset - len(current))
|
||||
self.kvs[key] = current[:offset] + value
|
||||
except KeyError:
|
||||
raise FakeRadosModule.ObjectNotFound
|
||||
|
||||
def stat(self, key):
|
||||
self._validate_key(key)
|
||||
|
Loading…
Reference in New Issue
Block a user