Skip to content

Conversation

ellemouton
Copy link
Member

Since we convert to UTC timestamps at persistence read/write time, we gotta make sure to compare against a consistent Local when comparing against time.Now() in the code.

@ellemouton ellemouton self-assigned this Feb 12, 2025
Copy link
Contributor

@ViktorTigerstrom ViktorTigerstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a few small comments.

@@ -190,7 +190,7 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
req *litrpc.AddSessionRequest) (*litrpc.AddSessionResponse, error) {

expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one should also be:

Suggested change
expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0)
expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0).UTC()

Or we need to update protos to declare that the timestamp should explicitly be sent in through the request in UTC?

@@ -839,7 +839,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
}

expiry := time.Unix(int64(req.ExpiryTimestampSeconds), 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines 135 to +137
startTime := time.Now().Add(
-time.Duration(rateLim.NumHours) * time.Hour,
)
).UTC()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be:

	startTime := time.Now().UTC().Add(
		-time.Duration(rateLim.NumHours) * time.Hour,
	)

Else there can be an discrepancy when the local timezone conversion happens right at a boundary of DST.

@ellemouton
Copy link
Member Author

thank goodness we dont need this

@ellemouton ellemouton closed this Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants