From f984e9d0eb6edab95bcbb435affd078f06005fb1 Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Tue, 25 Feb 2014 16:55:46 +0000 Subject: [PATCH] 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 --- ceilometer/storage/impl_db2.py | 2 ++ ceilometer/storage/impl_mongodb.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ceilometer/storage/impl_db2.py b/ceilometer/storage/impl_db2.py index ef7e28b03..237fc2516 100644 --- a/ceilometer/storage/impl_db2.py +++ b/ceilometer/storage/impl_db2.py @@ -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): diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index 5b5d92a02..49a10fe52 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -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):