Bug 1109917 - prefer gf_time_fmt() instead of strftime()
Summary: prefer gf_time_fmt() instead of strftime()
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: core
Version: mainline
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kaleb KEITHLEY
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-16 15:42 UTC by Kaleb KEITHLEY
Modified: 2015-02-12 20:05 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-12 20:05:43 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Kaleb KEITHLEY 2014-06-16 15:42:35 UTC
Description of problem:

use of localtime()+strfime() to print time values for logging is creeping into the source. Logging (on an appliance, by design and by community agreement) should be in UTC (a.k.a. GMT) and should be consistent across the board. Back in the 3.3 timeframe gf_time_fmt() was added to simplify this.

Additionally there are two places where a time_t is printed as a integer number. The only way to do this portably on systems with 32-bit and 64-bit time_t is with strftime(..., "%s"), and not with things like *printf(..., "%lld").

Comment 1 Anand Avati 2014-06-16 16:38:44 UTC
REVIEW: http://review.gluster.org/8085 (core: use gf_time_fmt() instead of localtime()+strftime()) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 2 Anand Avati 2014-06-16 17:35:46 UTC
REVIEW: http://review.gluster.org/8085 (core: use gf_time_fmt() instead of localtime()+strftime()) posted (#2) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 3 Anand Avati 2014-06-18 12:25:04 UTC
REVIEW: http://review.gluster.org/8085 (core: use gf_time_fmt() instead of localtime()+strftime()) posted (#3) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 4 Anand Avati 2014-09-21 06:26:01 UTC
REVIEW: http://review.gluster.org/8085 (core: use gf_time_fmt() instead of localtime()+strftime()) posted (#4) for review on master by Harshavardhana (harsha)

Comment 5 Anand Avati 2014-11-20 14:59:26 UTC
COMMIT: http://review.gluster.org/8085 committed in master by Vijay Bellur (vbellur) 
------
commit 9797bd197d48ca17a124c245295937ac3d48ab58
Author: Kaleb S. KEITHLEY <kkeithle>
Date:   Mon Jun 16 12:29:03 2014 -0400

    core: use gf_time_fmt() instead of localtime()+strftime()
    
    gf_time_fmt() has existed since 3.3; it provides consistent timestamps
    (i.e. UTC times) throughout the implementation. (BTW, the other name for UTC
    is GMT.)
    
    N.B. many (all?) commercial storage solutions use UTC time for logging.
    This makes for easier debugging across geographically distributed systems.
    
    Also adding a "%s" fmt for portably printing time as simple numeric
    value on systems regardless of whether 32-bit or 64-bit time_t. Plus a
    minor tweak to return a ptr to the dest-string to allow gf_time_fmt()
    to be passed as a param in a *printf().
    
    Someday we should pick the "one true" timestamp format and revise all
    calls to gf_time_fmt() to use it instead of the five or six different
    formats.
    
    Change-Id: I78202ae14b7246fa424efeea56bf2463e14abfb0
    BUG: 1109917
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Reviewed-on: http://review.gluster.org/8085
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Niels de Vos <ndevos>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 6 Kaleb KEITHLEY 2015-02-12 20:05:43 UTC
I believe this has made it into the 3.6 branch and been released.


Note You need to log in before you can comment on or make changes to this bug.