-
Notifications
You must be signed in to change notification settings - Fork 103
multi: be consistent with UTC conversion of timestamp #976
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -132,7 +132,7 @@ func (s *sessionRpcServer) start(ctx context.Context) error { | |||||
continue | ||||||
} | ||||||
|
||||||
if sess.Expiry.Before(time.Now()) { | ||||||
if sess.Expiry.Before(time.Now().UTC()) { | ||||||
continue | ||||||
} | ||||||
|
||||||
|
@@ -190,7 +190,7 @@ func (s *sessionRpcServer) AddSession(ctx context.Context, | |||||
req *litrpc.AddSessionRequest) (*litrpc.AddSessionResponse, error) { | ||||||
|
||||||
expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this one should also be:
Suggested change
Or we need to update protos to declare that the timestamp should explicitly be sent in through the request in UTC? |
||||||
if time.Now().After(expiry) { | ||||||
if time.Now().UTC().After(expiry) { | ||||||
return nil, fmt.Errorf("expiry must be in the future") | ||||||
} | ||||||
|
||||||
|
@@ -364,7 +364,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |||||
} | ||||||
|
||||||
// Don't resume an expired session. | ||||||
if sess.Expiry.Before(time.Now()) { | ||||||
if sess.Expiry.Before(time.Now().UTC()) { | ||||||
log.Debugf("Not resuming session %x with expiry %s", | ||||||
pubKeyBytes, sess.Expiry) | ||||||
|
||||||
|
@@ -440,15 +440,15 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |||||
// we do not yet have a static remote pub key for. | ||||||
if sess.RemotePublicKey == nil { | ||||||
deadline := sess.CreatedAt.Add(s.cfg.firstConnectionDeadline) | ||||||
if deadline.Before(time.Now()) { | ||||||
if deadline.Before(time.Now().UTC()) { | ||||||
log.Debugf("Deadline for session %x has already "+ | ||||||
"passed. Revoking session", pubKeyBytes) | ||||||
|
||||||
return s.cfg.db.RevokeSession(pubKey) | ||||||
} | ||||||
|
||||||
// Start the deadline timer. | ||||||
deadlineDuration := time.Until(deadline) | ||||||
deadlineDuration := deadline.Sub(time.Now().UTC()) | ||||||
deadlineTimer := time.AfterFunc(deadlineDuration, func() { | ||||||
close(firstConnTimout) | ||||||
}) | ||||||
|
@@ -489,7 +489,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context, | |||||
go func() { | ||||||
defer s.wg.Done() | ||||||
|
||||||
ticker := time.NewTimer(time.Until(sess.Expiry)) | ||||||
ticker := time.NewTimer(sess.Expiry.Sub(time.Now().UTC())) | ||||||
defer ticker.Stop() | ||||||
|
||||||
select { | ||||||
|
@@ -839,7 +839,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context, | |||||
} | ||||||
|
||||||
expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||||||
if time.Now().After(expiry) { | ||||||
if time.Now().UTC().After(expiry) { | ||||||
return nil, fmt.Errorf("expiry must be in the future") | ||||||
} | ||||||
|
||||||
|
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 should be:
Else there can be an discrepancy when the local timezone conversion happens right at a boundary of
DST
.