Project

General

Profile

Actions

Bug #17138

closed

Date precision inconsistencies between (for example) collections#show and collections#list

Added by Lucas Di Pentima over 3 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Normal
Assigned To:
-
Category:
API
Target version:
-
Story points:
-

Description

While working on avoiding unnecessary re-renderings on workbench2 I came across a problem with the API server:

Retrieving the same collection from the above mentioned endpoints gave me different date precision formats, for example:

2020-10-07T19:32:42.993304Z (collections#list)

versus

2020-10-07T19:32:42.993304000Z (collections#show)

This is a problem because the etag digest is different on every case, even though they're the same collection.

Actions #1

Updated by Lucas Di Pentima over 3 years ago

  • Description updated (diff)
  • Subject changed from Date precision inconsistencies between (for example) collections#show and groups#contents to Date precision inconsistencies between (for example) collections#show and collections#list

Errata: the discrepancy is between #show and #list endpoints from collections (probably also on other resource types)

Actions #2

Updated by Lucas Di Pentima over 3 years ago

The problem seems to be on collections#list:

$ arv collection list | jq .items[0].created_at
"2020-10-07T19:32:42.993304Z" 
$ arv group list | jq .items[0].created_at
"2020-10-20T22:05:42.392489000Z" 
$ arv container list | jq .items[0].created_at
"2020-10-19T16:35:12.026524000Z" 
$ arv container_request list | jq .items[0].created_at
"2020-10-19T16:35:12.057875000Z" 
Actions #3

Updated by Lucas Di Pentima over 3 years ago

There's an explicit test con CollectionsController at services/api/test/functional/arvados/v1/filters_test.rb called 'api responses provide timestamps with nanoseconds' that passes without issues. OTOH, I've just double checked this on ce8i5 and it behaves as reported here.

Actions #4

Updated by Lucas Di Pentima over 3 years ago

Making the request directly to railsAPI works OK:

root@d0b854923e28:/# curl  -H "Authorization: OAuth2 xxxxtokenxxxxx" http://localhost:8004/arvados/v1/collections | jq .items[0].created_at
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10615    0 10615    0     0   334k      0 --:--:-- --:--:-- --:--:--  334k
"2020-10-07T19:32:42.993304000Z" 
Actions #5

Updated by Nico César over 3 years ago

looks like it comes from:lib/controller/router/response.go

for k, v := range tmp {
        if strings.HasSuffix(k, "_at") {
            // Format non-nil timestamps as
            // rfc3339NanoFixed (otherwise they
            // would use the default time encoding).
            switch tv := v.(type) {
            case *time.Time:
                if tv == nil {
                    break
                }
                tmp[k] = tv.Format(rfc3339NanoFixed)
            case time.Time:
                if tv.IsZero() {
                    tmp[k] = nil
                } else {
                    tmp[k] = tv.Format(rfc3339NanoFixed)
                }
Actions #6

Updated by Lucas Di Pentima over 3 years ago

Ok, so for the record: The original issue of getting a different etag field isn't because controller rewrites the dates in different format, but because the same collection is retrieved via different endpoints, and one of them doesn't include manifest_text so of course the digest changes.

Actions #7

Updated by Peter Amstutz over 3 years ago

  • Status changed from New to Rejected
Actions #8

Updated by Peter Amstutz over 3 years ago

  • Target version deleted (2020-12-02 Sprint)
Actions

Also available in: Atom PDF