Skip to content

Report a missing index as 404 from index servers of any store - #457

Open
folbricht wants to merge 1 commit into
masterfrom
fix-index-server-not-found
Open

folbricht wants to merge 1 commit into
masterfrom
fix-index-server-not-found

Conversation

@folbricht

Copy link
Copy Markdown
Owner

An index server answers a request for an index that doesn't exist with 400 Bad Request unless its store is a local directory. A client reading from such a server gets unexpected status code 400 instead of the missing-object error it gets from a server with a local store.

The handler used os.IsNotExist to tell a missing index from a failure to read one. That only matches the error a local store returns. The other index stores report a missing index in ways it doesn't recognise:

Store Error for a missing index
HTTP, OCI NoSuchObject
SFTP the not-exist error flattened into a new one with %v
GCS storage.ErrObjectNotExist, wrapped
S3 none from GetIndexReader; the S3 error surfaces from the first read

Changes:

  • NoSuchObject matches fs.ErrNotExist through an Is method, so errors.Is(err, fs.ErrNotExist) covers a missing index in any store, wrapped or not.
  • The index handler uses that test for GET and HEAD.
  • The SFTP and GCS index stores return NoSuchObject for a missing index.
  • The S3 index store reads ahead in GetIndexReader, which is when the object is actually requested, and returns NoSuchObject for NoSuchKey. This takes no extra request. It also corrects HEAD on an index server backed by S3, which answered 200 for any name since opening the reader never failed.

Other failures to read an index are answered with 400 as before.

The handler, the S3 store and the SFTP store have tests for a missing index. The GCS change has none, there is no fake GCS backend in the tests.

The index server used os.IsNotExist to tell a missing index from a
failure to read one, which only matches the error of a local store. For
every other store a missing index was answered with 400.

NoSuchObject now matches fs.ErrNotExist, the handler tests for that with
errors.Is, and the SFTP, GCS and S3 index stores return NoSuchObject for
an index that isn't there, like the HTTP and OCI ones. S3 only finds out
when the object is read, so its reader reads ahead to report it.
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.

1 participant