DateTime fields lose resolution when serialized

Bug #1933964 reported by Gorka Eguileor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cinderlib
Fix Released
Undecided
Gorka Eguileor

Bug Description

Cinderlib's methods and property that convert objects to json end up losing resolution on DateTime fields.

Since json doesn't have a datetime fields they are stored as strings, but they are not storing subsecond information.

This means that datetime fields that are serialized and then deserialized are different.

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

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinderlib/+/798633

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

Reviewed: https://review.opendev.org/c/openstack/cinderlib/+/798633
Committed: https://opendev.org/openstack/cinderlib/commit/51609b61a43d53119c8e8e00ae5ef5e919e85a27
Submitter: "Zuul (22348)"
Branch: master

commit 51609b61a43d53119c8e8e00ae5ef5e919e85a27
Author: Gorka Eguileor <email address hidden>
Date: Tue Jun 29 11:56:54 2021 +0200

    Fix datetime serialization

    Cinderlib's methods and property that convert objects to json end up
    losing resolution on DateTime fields.

    Since json doesn't have a datetime fields they are stored as strings,
    but they are not storing subsecond information.

    This means that datetime fields that are serialized and then
    deserialized are different.

    This patch changes the way we format the string to use the ISO-8601
    subsecond format instead of the standard second format.

    This is a backward compatible change, as this version of cinderlib will
    be able to read old datetime string, and old cinderlib code will be able
    to read new datetime strings as well (even if it cannot generate them).

    The old code is able to read the new format because the from_primitive
    code of the OVO field uses oslo_utils.timeutils.parse_isotime which in
    the end uses iso8601.parse_date, and since the subsecond format is also
    ISO8601 it is properly parsed.

    Change-Id: I1422e833ec0ec50376d4afac91f22c7b60bf996b
    Closes-Bug: #1933964

Changed in cinderlib:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinderlib 4.0.0

This issue was fixed in the openstack/cinderlib 4.0.0 release.

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.