-
Notifications
You must be signed in to change notification settings - Fork 70
logger: Fix nanosecond timestamp test #1018
logger: Fix nanosecond timestamp test #1018
Conversation
`TestNewSystemLogHook()` checks to ensure a nanonsecond timestamp is generated. However, the `time.RFC3339Nano` time format truncates trailing zeros meaning a nanosecond timestamp won't always have nine digits. Fixes clearcontainers#1017. Signed-off-by: James O. D. Hunt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one query, but other than that
lgtm
// nano-seconds. Note that the quantifier range is | ||
// required because the time.RFC3339Nano format | ||
// trunctates trailing zeros. | ||
`\d{1,9}` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just checking - I presume '0' comes out as '0', and hence always at least 1 digit? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, same question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. It isn't documented afaics but observationally there is always a leading zero, yes. I've also discovered something rather interesting by looking at the parsing code:
time.RFC3339Nano
truncates trailing zeros because it is defined like this:
RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
But, you can create a non-truncating format by switching the values after the decimal point to zeros!:
const RFC3339NanoNoTruncate = "2006-01-02T15:04:05.000000000Z07:00"
Kinda surprising someone didn't add that as a standard option given the documented sorting behaviour of time.RFC3339Nano
.
/cc @markdryan.
kubernetes qa-passed 👍 |
The metrics CI is again stopping the button from going green :-( Force-merging as everything else is happy and this is causing the new release on #1021 to fail CI. |
Just to note, the metrics CI failed due to a network/docker hub issue:
|
TestNewSystemLogHook()
checks to ensure a nanonsecond timestamp isgenerated. However, the
time.RFC3339Nano
time format truncatestrailing zeros meaning a nanosecond timestamp won't always have nine
digits.
Fixes #1017.
Signed-off-by: James O. D. Hunt [email protected]