Bug 1371844

Summary: Drop leap second in python-oslo-utils-1.1.0-2
Product: Red Hat OpenStack Reporter: Irina Petrova <ipetrova>
Component: python-oslo-utilsAssignee: Victor Stinner <vstinner>
Status: CLOSED ERRATA QA Contact: Udi Shkalim <ushkalim>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.0 (Juno)CC: apevec, jbuchta, jschluet, lhh, ushkalim, vstinner
Target Milestone: ---Keywords: ZStream
Target Release: 6.0 (Juno)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-oslo-utils-1.1.0-3.el7ost Doc Type: Bug Fix
Doc Text:
Bugfix to support properly leap seconds.
Story Points: ---
Clone Of:
: 1371859 (view as bug list) Environment:
Last Closed: 2016-12-21 16:52:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1371859    

Description Irina Petrova 2016-08-31 08:59:13 UTC
OSP6 latest python-oslo-utils package:

python-oslo-utils-1.1.0-2.el7ost.noarch

does NOT include leap-second fix introduced in version 1.5:

~~~python-oslo-utils-1.1.0-2.el7ost:

def unmarshall_time(tyme):
    """Unmarshall a datetime dict."""
    return datetime.datetime(day=tyme['day'],
                             month=tyme['month'],
                             year=tyme['year'],
                             hour=tyme['hour'],
                             minute=tyme['minute'],
                             second=tyme['second'],
                             microsecond=tyme['microsecond'])


def delta_seconds(before, after):

~~~

~~~ python-oslo-utils-2.8.0-1.el7ost:

def unmarshall_time(tyme):
    """Unmarshall a datetime dict.

    .. versionchanged:: 1.5   <------------------------------------
       Drop leap second.      <------------------------------------

    .. versionchanged:: 1.6
       Added support for timezone information.
    """

    # NOTE(ihrachys): datetime does not support leap seconds,
    # so the best thing we can do for now is dropping them
    # http://bugs.python.org/issue23574
    second = min(tyme['second'], _MAX_DATETIME_SEC)
    dt = datetime.datetime(day=tyme['day'],
                           month=tyme['month'],
                           year=tyme['year'],
                           hour=tyme['hour'],
                           minute=tyme['minute'],
                           second=second,
                           microsecond=tyme['microsecond'])
    tzname = tyme.get('tzname')
    if tzname:
        tzinfo = timezone(tzname)
        dt = tzinfo.localize(dt)
    return dt

~~~

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

Comment 2 Victor Stinner 2016-09-21 15:41:33 UTC
A package is now ready for tests. I don't know how to test the fix in practice, leap seconds are are :-) At least, unit tests pass.

Comment 3 Victor Stinner 2016-09-21 15:51:25 UTC
Oops, wrong issue.

Comment 4 Victor Stinner 2016-09-21 16:16:33 UTC
Sorry, the right package is in fact the freshly built python-oslo-utils-1.1.0-3.el7ost.

Comment 5 Irina Petrova 2016-11-02 10:19:50 UTC
Hey guys, can we move this forward?

It's been fixed in OSP7 (BZ 1371859), and it seems to me that we also already have it in OSP6 (Fixed In Version: python-oslo-utils-1.1.0-3.el7ost).

What is needed next? doc_text ACK?

--Irina

Comment 9 Irina Petrova 2016-12-19 14:13:16 UTC
Guys, are we making any progress on this?

https://time.is/leapsecond >>> as of this writing, leap second 2016 is going to occur in less than 12 days

Wouldn't it be nice if we could get the patch out before that?

--Irina

Comment 10 Lon Hohberger 2016-12-20 18:21:44 UTC
Simple test:

import timeutils

t1 = {'day': 31,
      'month': 12,
      'year': 2016,
      'hour': 23,
      'minute': 59,
      'second': 59,
      'microsecond': 0 }

t2 = {'day': 31,
      'month': 12,
      'year': 2016,
      'hour': 23,
      'minute': 59,
      'second': 60,
      'microsecond': 0 }

print timeutils.unmarshall_time(t1)
# Before patch: traceback. After patch:
# Same result as above
print timeutils.unmarshall_time(t2)


Before patch:

2016-12-31 23:59:59
Traceback (most recent call last):
  File "foo", line 22, in <module>
    print timeutils.unmarshall_time(t2)
  File "/home/lhh/tmp/tmp/usr/lib/python2.7/site-packages/oslo/utils/timeutils.py", line 182, in unmarshall_time
    microsecond=tyme['microsecond'])
ValueError: second must be in 0..59

After patch to drop leap second:

2016-12-31 23:59:59
2016-12-31 23:59:59

Comment 11 Victor Stinner 2016-12-20 18:32:55 UTC
Thanks for testing Lon ;-)

Comment 12 Irina Petrova 2016-12-21 11:20:38 UTC
Thanks, Lon!

Comment 14 errata-xmlrpc 2016-12-21 16:52:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2979.html