Skip to content
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

Try Getting Time from Server for List Calls #567

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BrentSouza
Copy link

We have noticed that s5cmd ls sometimes fails to list objects immediately after they are written. This seems to be related to clock skew since s5cmd gets the current time from the client and compares it against each object's lastModified date. This is detailed a bit in issue #531

In our case, S3 servers seem to be a couple seconds ahead of our servers (which are synced with NTP servers so not sure where the issue lies). While troubleshooting, we did notice that the Date header from S3's http responses lined up with the future times we saw in the lastModified metadata.

This patch will request the Date header from the response and use it for the timestamp. It will fallback to the client's current time if the header is not present or in the event that the date cannot be parsed.

I've modified the tests to check for both scenarios and locally all unit test are working. Please let me know if there are any additional checks you'd like me to run.

@BrentSouza BrentSouza requested a review from a team as a code owner May 15, 2023 18:12
@BrentSouza BrentSouza requested review from ilkinulas and seruman and removed request for a team May 15, 2023 18:12
@mwkaufman
Copy link

I built this locally and it did now successfully return the future-dated (rounded up to the next whole second) object in our environment.

// track the instant object iteration began,
// so it can be used to bypass objects created after this instant
if now.IsZero() {
now = time.Now().UTC()
if serverDate != "" {
n, err := http.ParseTime(serverDate)
Copy link
Member

Choose a reason for hiding this comment

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

http.ParseTime function is not able to accurately represent the last modified time of an S3 object, because the latter has a much higher precision. This is causing the tests to fail.

For example:

  • Parsed time in header : 2023-07-01 19:43:58 +0000 UTC
  • Last Modified time of S3 object: 2023-07-01 19:43:58.058 +0000 UTC

I will let you know if I am able to find a solution to the time comparison issue.

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.

4 participants