singularityhub / singularityhub.github.io

Container tools for scientific computing! Docs at https://singularityhub.github.io/singularityhub-docs
https://singularityhub.github.io
68 stars 9 forks source link

HTTP Code is 200 OK when body indicates an error #212

Closed dtrudg closed 4 years ago

dtrudg commented 4 years ago

Version of Singularity

3.5.3

Error on Singularity Hub

dave@piran~> singularity -d pull shub://vsoch/hello-world
DEBUG   [U=1000,P=123008]  persistentPreRunE()           Singularity version: 3.5-1.el7
DEBUG   [U=1000,P=123008]  handleConfDir()               /home/dave/.singularity already exists. Not creating.
DEBUG   [U=1000,P=123008]  handleRemoteConf()            Ensuring file permission of 0600 on /home/dave/.singularity/remote.yaml
DEBUG   [U=1000,P=123008]  getCacheBasedir()             environment variable SINGULARITY_CACHEDIR not set, using default image cache
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/library
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/oci-tmp
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/oci
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/net
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/shub
DEBUG   [U=1000,P=123008]  updateCacheSubdir()           Caching directory set to /home/dave/.singularity/cache/oras
DEBUG   [U=1000,P=123008]  GetManifest()                 shub request: https://singularity-hub.org/api/container/vsoch/hello-world:latest
DEBUG   [U=1000,P=123008]  GetManifest()                 200 OK response received, beginning manifest download
DEBUG   [U=1000,P=123008]  GetManifest()                 manifest image name: 
FATAL   [U=1000,P=123008]  pullRun()                     While pulling shub image: failed to get manifest for: shub://vsoch/hello-world: json: cannot unmarshal number into Go value of type client.ShubAPIResponse

What do you think is going on?

Singularity Hub is returning a response that is the text '429' (too many requests), but the HTTP status code on the response is 200 - so Singularity is trying to interpret it as a successful request.

dave@piran~> curl -v https://singularity-hub.org/api/container/vsoch/hello-world:latest
...
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.13.5
< Date: Wed, 22 Apr 2020 13:48:21 GMT
< Content-Type: application/json
< Content-Length: 3
< Connection: keep-alive
< Vary: Accept, Cookie
< Allow: GET, HEAD, OPTIONS
< X-Frame-Options: SAMEORIGIN
< 
* Connection #0 to host singularity-hub.org left intact
429⏎   

The HTTP code on the response should be set to 429 rather than 200 OK so that clients raise the appropriate error.

vsoch commented 4 years ago

Yeah I’m aware of this. For now just assume that the body of 429 indicates this error. I won’t be doing server work for some time.

vsoch commented 4 years ago

Code is updated, will go live with next round of server work (and I'll update the issue here).

vsoch commented 4 years ago

okay the server is updated, so the issue should be resolved (the response message is formatted as you specified with the correct status). Thanks for reporting this, sorry for the delay, and please re-open if anyone reports issue.

dtrudg commented 4 years ago

:+1:

FATAL   [U=1000,P=42195]   pullRun()                     While pulling shub image: error fetching image to cache: failed to get manifest for: shub://vsoch/hello-world: 429 Too Many Requests
vsoch commented 4 years ago

hooray! So happy to see an error message (said no one ever, except for today!) Have a good weekend @dctrud and thanks again.