Tolerate absent recorded_at on older mongo/db2 samples

Fixes bug 1284608

Prevents failure of a samples query against a mongo-like instance
(i.e. either mongodb or db2) selecting metering data that predates
the advent of the recorded_at attribute for samples:

  Ia0ff8bd07fd811fe8d3050d30971a05a277798d0

Change-Id: If480321923e9166583bbea91c3878950bafbedf1
This commit is contained in:
Eoghan Glynn 2014-02-25 16:55:46 +00:00
parent bf8f536529
commit f984e9d0eb
2 changed files with 4 additions and 0 deletions

View File

@ -354,6 +354,8 @@ class Connection(pymongo_base.Connection):
del s['_id']
# Backward compatibility for samples without units
s['counter_unit'] = s.get('counter_unit', '')
# Tolerate absence of recorded_at in older datapoints
s['recorded_at'] = s.get('recorded_at')
yield models.Sample(**s)
def get_meter_statistics(self, sample_filter, period=None, groupby=None):

View File

@ -611,6 +611,8 @@ class Connection(pymongo_base.Connection):
del s['_id']
# Backward compatibility for samples without units
s['counter_unit'] = s.get('counter_unit', '')
# Tolerate absence of recorded_at in older datapoints
s['recorded_at'] = s.get('recorded_at')
yield models.Sample(**s)
def get_samples(self, sample_filter, limit=None):