s5cmd icon indicating copy to clipboard operation
s5cmd copied to clipboard

Try Getting Time from Server for List Calls

Open BrentSouza opened this issue 2 years ago • 1 comments

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 avatar May 15 '23 18:05 BrentSouza

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

mwkaufman avatar May 15 '23 18:05 mwkaufman