New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support rfc3339 micro-sec (6 digit) timestamp #1477
Support rfc3339 micro-sec (6 digit) timestamp #1477
Conversation
.optionalEnd() | ||
.appendLiteral("Z") | ||
.toFormatter(); | ||
|
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.
I'm not sure this is necessary. Why do we need an explicit formatter for a format that already works by default with OffsetDateTime
(I believe)?
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.
kubernetes server-side requires 6-digit fraction for micro timestamp types (e.g. LeaseSpec#accquireTime) where "0" should be padded in the end if necessary. however, the default DateTimeFormatter.ISO_OFFSET_DATE_TIME
doesn't support right-padding for micro-sec timestamps. e.g. by the default formatter2018-04-03T11:32:26.1234Z
is a valid timestamp, but kubernetes server will be rejecting b/c lacking right-padded "0"s, it's expected to be 2018-04-03T11:32:26.123400Z
spec = | ||
spec.acquireTime( | ||
OffsetDateTime.ofInstant( | ||
Instant.ofEpochMilli(record.getAcquireTime().getTime()), ZoneOffset.UTC)); |
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.
This drops the milliseconds, right? Is that the intention? It also assumes that the timestamps are all UTC (but I think that is guaranteed by the k8s spec if they come from the server).
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.
yes, the leader-elector manages resource-locks w/ millis-sec timestamp, so it doesn't make a difference whether LeaseLock
provides extra precision.
This LGTM but I will wait for an ack from @dsyer |
I see what this does now, and while I hate to add even more manual overrides to the |
I also think there might be a problem with using |
@dsyer i made the formatter private in the latest commit
refactoring the leader-elector to use OffsetDateTime to track the lease record sounds good to me. but i think we should defer that in a separate follow-up to unwound the e2e failure ASAP. |
LGTM then. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, yue9944882 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@brendandburns @dsyer
it's a follow-up of #1418.
this pull will force the timestamp types to be serialized including 6 digit of fraction in order to support the precision of micro-second.
the original kubernetes go types basically accepts two kinds of timestamp in RFC3339:
RFC3339 = "2006-01-02T15:04:05Z07:00"
for the go type metav1.TimeRFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
for the go type metav1.MicroTimeat the kubernetes server side, (2) can be implicitly casted to (1) if extra precision is provided. ideally java model should discriminate (1) and (2) w/ separate java types so that we can switch the precision dynamically upon serialization. however, that's infeasible for now b/c the published openapi spec from kubernetes server is marking (1) and (2) as the same openapi schema types.
the bright side is that discriminating time types in different precision w/ different java types can be odd aesthetically..