From 6e470bc37bbbd34bfb1512f3531b86c18089388a Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Tue, 19 Dec 2017 11:57:05 +0100 Subject: [PATCH] Fix UsageEnd in CSV reports This fixes the value of UsageEnd in CSV reports. Currently, it is always equal to the usage_start of the first processed dataframe + one collect period. It was an issue with the first condition of _get_usage_end(): given that _get_usage_start() was always called before _get_usage_end(), the condition was always true and cached_end was never updated. Change-Id: Ice8f3b291a2b1327b9b95e1974de1431a93fd29e Story: 2001414 Task: 6112 --- cloudkitty/writer/csv_map.py | 3 ++- releasenotes/notes/fix-csv-usage-end-7bcf4cb5effc4461.yaml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-csv-usage-end-7bcf4cb5effc4461.yaml diff --git a/cloudkitty/writer/csv_map.py b/cloudkitty/writer/csv_map.py index 5c1803e0..f0d3e8a9 100644 --- a/cloudkitty/writer/csv_map.py +++ b/cloudkitty/writer/csv_map.py @@ -95,7 +95,8 @@ class CSVMapped(csv_base.BaseCSVBackend): """Get the end usage of this period. """ - if self.cached_start == self.usage_start and self.cached_end_str: + if self.cached_start == self.usage_start and self.cached_end_str \ + and self.cached_end > self.cached_start: return self.cached_end_str else: usage_end = self.usage_start_dt + datetime.timedelta( diff --git a/releasenotes/notes/fix-csv-usage-end-7bcf4cb5effc4461.yaml b/releasenotes/notes/fix-csv-usage-end-7bcf4cb5effc4461.yaml new file mode 100644 index 00000000..8137d8a5 --- /dev/null +++ b/releasenotes/notes/fix-csv-usage-end-7bcf4cb5effc4461.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + The value of the UsageEnd field in CSV reports has been fixed.