Incorrect datetime value in bw_usage_update

Bug #1442795 reported by Andrew Laski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Lianhao Lu

Bug Description

2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task File "/opt/rackstack/rackstack.228.7/nova/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task cursor.execute(statement, parameters)
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task File "/opt/rackstack/rackstack.228.7/nova/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task self.errorhandler(self, exc, value)
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task File "/opt/rackstack/rackstack.228.7/nova/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task raise errorclass, errorvalue
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task OperationalError: (OperationalError) (1292, "Incorrect datetime value: '2015-04-10T00:00:00Z' for column 'start_period' at row 1") 'INSERT INTO bw_usage_cache (created_at, updated_at, deleted_at, deleted, uuid, mac, start_period, last_refreshed, bw_in, bw_out, last_ctr_in, last_ctr_out) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2015, 4, 10, 6, 25, 20, 129368), None, None, 0, '2176064f-0ae1-45a6-9142-d1b80255ff67', 'FE:ED:FA:00:17:CD', '2015-04-10T00:00:00Z', '2015-04-10T06:25:20Z', 0, 0, 2654, 2284)
2015-04-10 06:25:20.134 15041 TRACE nova.openstack.common.periodic_task

The serialize_args wrapper for objects.BandwidthUsage().create() is converting the datetime to a string which mysql doesn't like.

Revision history for this message
Lianhao Lu (lianhao-lu) wrote :

Hmm, seems this can only reproduced by using xenapi virt driver, since currently it's the only driver which supports get_all_bw_counters().

Anyhow, the serialize_args wrapper seems convert datetime into a wrong format

Changed in nova:
assignee: nobody → Lianhao Lu (lianhao-lu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Changed in nova:
assignee: Lianhao Lu (lianhao-lu) → Hans Lindgren (hanlind)
Changed in nova:
assignee: Hans Lindgren (hanlind) → Lianhao Lu (lianhao-lu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to nova (master)

Reviewed: https://review.openstack.org/174243
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=83cdec4123dba74ace3439204df9a76d0053ebe7
Submitter: Jenkins
Branch: master

commit 83cdec4123dba74ace3439204df9a76d0053ebe7
Author: Hans Lindgren <email address hidden>
Date: Wed Apr 15 11:42:32 2015 +0200

    Make objects serialize_args() handle datetimes in positional args

    Remotable methods in a new TaskLog object need to serialize datatimes
    passed as positional args. Right now the serialize_args() decorator only
    look at kwargs.

    In addition, serialization of datetimes need to use timeutils.strtime()
    to match the deserialization code in the db api. Also makes this change
    for serialization of kwargs to partially solve a bug with how this
    decorator is used in the BandwidthUsage object.

    A follow-up patch closes the bug by adding conversion back to datetimes
    using existing db api helper method convert_objects_related_datetimes(),
    which in turn makes use of timeutils.parse_strtime().

    Related to blueprint liberty-objects

    Change-Id: Ia87be4fd37bee499510ae543e11029c2013d4905
    Related-Bug: #1442795

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/173213
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=35c0fefd6a87ac884f8d396be40e39ae283e6424
Submitter: Jenkins
Branch: master

commit 35c0fefd6a87ac884f8d396be40e39ae283e6424
Author: Lianhao Lu <email address hidden>
Date: Fri Apr 17 09:28:14 2015 +0800

    Convert bandwidth_usage related timestamp to UTC native datetime

    In sqlalchemy DB API, convert timestamp string related to
    bandwidth_usage operations into UTC native datetime.

    Closes-Bug: #1442795
    Change-Id: Icbf9ff73b867a5cc3bb9f5eb6a13ad954d7c44f6

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: liberty-1 → 12.0.0
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.