Fix usage of deprecated methods from oslo.utils.timeutils

Bug #1479056 reported by ChangBo Guo(gcb)
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Gábor Antal

Bug Description

We deprecated some methods isotime and strtime since oslo.utils 1.6.0, need clean up these methods.

For more details , search 'deprecated' in ' https://github.com/openstack/oslo.utils/blob/master/oslo_utils/timeutils.py

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

we can find some warning in jekins job logs like:

2015-07-23 07:05:25.242 | Captured stderr:
2015-07-23 07:05:25.242 | ~~~~~~~~~~~~~~~~
2015-07-23 07:05:25.242 | nova/context.py:181: DeprecationWarning: Using function/method 'oslo_utils.timeutils.strtime()' is deprecated in version '1.6' and will be removed in a future version: use either datetime.datetime.isoformat() or datetime.datetime.strftime() instead
2015-07-23 07:05:25.242 | self, 'timestamp') else None,
2015-07-23 07:05:25.242 | /home/jenkins/workspace/gate-nova-python27/.tox/py27/local/lib/python2.7/site-packages/oslo_versionedobjects/fields.py:338: DeprecationWarning: Using function/method 'oslo_utils.timeutils.isotime()' is deprecated in version '1.6' and will be removed in a future version: use datetime.datetime.isoformat()
2015-07-23 07:05:25.243 | return timeutils.isotime(value)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to nova (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/206624

Changed in nova:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → ChangBo Guo(gcb) (glongwave)
Revision history for this message
AMRITANSHU (amritgeo) wrote : Re: Fix deprecated methods in oslo.utils.timeutils

Please explain what you are trying to do

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Matt Riedemann (<email address hidden>) on branch: master
Review: https://review.openstack.org/206624
Reason: No changes since July so this looks abandoned. Please restore and rebase if you plan on working on this. Someone else in IRC expressed an interest in working on this same bug.

Matt Riedemann (mriedem)
Changed in nova:
assignee: ChangBo Guo(gcb) (glongwave) → nobody
status: In Progress → Confirmed
summary: - Fix deprecated methods in oslo.utils.timeutils
+ Fix usage of deprecated methods from oslo.utils.timeutils
Changed in nova:
assignee: nobody → Stephen Finucane (sfinucan)
Revision history for this message
Diana Clarke (diana-clarke) wrote :

I also worked on removing these warnings, but I took a slightly different approach.

    https://review.openstack.org/#/c/240411

You were explicit, and included the format in all cases:

    BEFORE: timeutils.strtime(timeutils.utcnow())
    AFTER: timeutils.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')

Where as my goal was to move toward the simpler .isoformat() where possible:

    BEFORE: timeutils.strtime(timeutils.utcnow())
    AFTER: timeutils.utcnow().isoformat()

The catch is that datetime.isoformat() is not *exactly* the same as '%Y-%m-%dT%H:%M:%S.%f' (when microseconds is 0), but in practice it's probably fine since they are pretty much always timeutils.utcnow() with microseconds. To err on the side of caution though, I intentionally did not change 5 instances of timeutils.strtime in the production path code (vs the unit tests) to be revisited later.

    https://docs.python.org/2/library/datetime.html#datetime.datetime.isoformat

That said, I like a combination of both of our approaches: isoformat when it's safe, and an explicit '%Y-%m-%dT%H:%M:%S.%f' in the production code path when there's some doubt about remaining backwards compatible. I'll update my patch to combine both approaches and add you as an additional author.

Changed in nova:
assignee: Stephen Finucane (sfinucan) → Diana Clarke (diana-clarke)
status: Confirmed → In Progress
Revision history for this message
Diana Clarke (diana-clarke) wrote :

There were two slightly different approaches proposed yesterday & today:

   https://review.openstack.org/#/c/240411/

   https://review.openstack.org/#/c/240593/

I can see pros & cons to both, so I encourage any reviewers to review both.

I'm especially curious to know what the oslo folks that deprecated the functions think, knowing the recommended alternatives aren't 100% backwards compatible. I'm sure there must have been some kind of discussion at the time of deprecation.

Changed in nova:
assignee: Diana Clarke (diana-clarke) → nobody
Changed in nova:
assignee: nobody → Stephen Finucane (sfinucan)
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/241179

Changed in nova:
assignee: Stephen Finucane (sfinucan) → Gábor Antal (gabor.antal)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Diana Clarke (<email address hidden>) on branch: master
Review: https://review.openstack.org/240411
Reason: There are now a few patches in the queue to fix this. Abandoning this one in the hopes that one of them actually gets merged.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Stephen Finucane (<email address hidden>) on branch: master
Review: https://review.openstack.org/240593
Reason: Diana Clarke: I agree. It's unfortunate to have had so much overlap, but the best solution appears to be the one you linked.

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

Reviewed: https://review.openstack.org/241179
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=630aad025e2d7010d60a2b2257959692e35bbb3f
Submitter: Jenkins
Branch: master

commit 630aad025e2d7010d60a2b2257959692e35bbb3f
Author: Gábor Antal <email address hidden>
Date: Tue Nov 3 13:10:47 2015 +0100

    Replaced deprecated timeutils methods

    Since oslo 1.6.0 timeutils.isotime() and timeutils.strtime() methods
    are deprecated.
     DeprecationWarning: Using function/method
     'oslo_utils.timeutils.strtime()' is deprecated in version '1.6' and
     will be removed in a future version: use either
     datetime.datetime.isoformat() or datetime.datetime.strftime() instead

    Change-Id: If69bd8a6bee052556ba8853afef3941bcd1e7b13
    Closes-Bug: 1479056
    Co-Authored-By: Diana Clarke <email address hidden>

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/nova 13.0.0.0b1

This issue was fixed in the openstack/nova 13.0.0.0b1 development milestone.

Changed in nova:
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.