Default usage-list range is in local time, not UTC time

Bug #1045456 reported by Mark McLoughlin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
High
Mark McLoughlin

Bug Description

The usage-list API expects a date range in UTC, since this is the TZ that e.g. terminated_at and launched_at is stored in the DB

In novaclient, we do:

        start = (datetime.datetime.today() -
                 datetime.timedelta(weeks=4))

        end = (datetime.datetime.today() +
                 datetime.timedelta(days=1))

You can see the effect of this here:

  https://bugs.launchpad.net/nova/+bug/1043999/comments/1

We're seeing 20 hours usage for an instance just started. Because of bug #1043999, that should be 24 hours but because Russell is UTC-4 we see 20 hours.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/12326

Changed in python-novaclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/12326
Committed: http://github.com/openstack/python-novaclient/commit/f2d2e4cb0621b27b2b3f864c4352a94174174240
Submitter: Jenkins
Branch: master

commit f2d2e4cb0621b27b2b3f864c4352a94174174240
Author: Mark McLoughlin <email address hidden>
Date: Mon Sep 3 20:06:09 2012 +0100

    Fix usage-list date range to use UTC time

    Fixes bug #1045456

    The date range in Nova's os-simple-tenant-usage is expected to be in UTC
    time since launch/termination dates are stored in the DB in UTC time and
    we use the client supplied parameters to query DB without conversion.

    Switch from using datetime.today() to datetime.utcnow() to fix the issue.

    Add a test for the default date range.

    Import timeutils from openstack-common so we can control the return value
    of utcnow() in the tests.

    Change-Id: Iac77e3a4cc9561714d1492c54cef931f9764531e

Changed in python-novaclient:
status: In Progress → Fix Committed
Changed in python-novaclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.