When users update setting in leap year, error will occur

Bug #1551099 reported by Kenji Ishii
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Eric Peterson

Bug Description

In leap year and on Feb 29, when users update user settings , error will occur.
This cause is calculation of cookie expiration. In this calculation, there is the case that a not exist day is specified.

Kenji Ishii (ken-ishii)
Changed in horizon:
assignee: nobody → Kenji Ishii (ken-ishii)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
status: New → In Progress
Revision history for this message
Matt Johnson (mj1856) wrote :

Do not try to add 365 days. You're just exchanging one type of leap year bug with another.

The problem is much more complicated than you might think, as you have to consider whether to add 365 or 366 days based on whether or not there's an instance of February 29th in the range being covered. Also, if you're using a time zone aware datetime, you also have to consider if you've crossed one or more time zone transitions (daylight saving time, etc.) in the specified time zone.

Instead, use the python-dateutil library: https://github.com/dateutil/dateutil/

http://stackoverflow.com/questions/15741618/add-one-year-in-current-date-python

new_date = datetime_object + relativedelta(years=1)

Changed in horizon:
assignee: Kenji Ishii (ken-ishii) → Eric Peterson (ericpeterson-l)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/285920
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=79c531a1c479a8f35ffb66dcf6daceb8dcf03a1a
Submitter: Jenkins
Branch: master

commit 79c531a1c479a8f35ffb66dcf6daceb8dcf03a1a
Author: Kenji Ishii <email address hidden>
Date: Mon Feb 29 16:43:35 2016 +0900

    Fix an error which cause on Feb 29 in user setting

    In Feb 29(leap year), when users update user settings, error will occur.
    Settings expiration is a year later and this calculation is incorrect.
    This patch will fix it.

    Change-Id: Id2bc6741ad3366969fbb73dc64c23430ce66f2aa
    Closes-Bug: #1551099

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
Matt Johnson (mj1856) wrote :

Note that the committed fix adds 365 days. If crossing Feb 29, then you'll be a day short. So next time around, when March 1st 2019 hits, one year out will calculate as February 29th 2020, instead of March 1st 2020.

If this is ONLY being used for cookie expiration, then this is fine. Just be careful if you start using it for other things.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/287728

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/horizon 9.0.0.0b3

This issue was fixed in the openstack/horizon 9.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (stable/liberty)

Reviewed: https://review.openstack.org/287728
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=bc0253d762a2fdde669bbf1feffa9970884882a5
Submitter: Jenkins
Branch: stable/liberty

commit bc0253d762a2fdde669bbf1feffa9970884882a5
Author: Kenji Ishii <email address hidden>
Date: Mon Feb 29 16:43:35 2016 +0900

    Fix an error which cause on Feb 29 in user setting

    In Feb 29(leap year), when users update user settings, error will occur.
    Settings expiration is a year later and this calculation is incorrect.
    This patch will fix it.

    Change-Id: Id2bc6741ad3366969fbb73dc64c23430ce66f2aa
    Closes-Bug: #1551099
    (cherry picked from commit 79c531a1c479a8f35ffb66dcf6daceb8dcf03a1a)

tags: added: in-stable-liberty
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 8.0.2

This issue was fixed in the openstack/horizon 8.0.2 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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