15521: Fix truncated index response.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 29 Oct 2019 14:18:40 +0000 (10:18 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 29 Oct 2019 14:18:40 +0000 (10:18 -0400)
The client (keep-balance) looks for a blank line at the end of the
index response as an assurance the response is not truncated.  If
headers have already been sent, http.Error("") writes a blank line --
so we were inadvertently assuring the client that truncated responses
were not truncated.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/keepstore/handlers.go

index 86504422d52f24f2659166e7cbfa975cb45772da..86de8fa194a65fbf99e9e53ecd30b574b1616843 100644 (file)
@@ -282,19 +282,15 @@ func (rtr *router) handleIndex(resp http.ResponseWriter, req *http.Request) {
 
        for _, v := range vols {
                if err := v.IndexTo(prefix, resp); err != nil {
-                       // We can't send an error message to the
-                       // client because we might have already sent
-                       // headers and index content. All we can do is
-                       // log the error in our own logs, and (in
-                       // cases where headers haven't been sent yet)
-                       // set a 500 status.
+                       // We can't send an error status/message to
+                       // the client because IndexTo() might have
+                       // already written body content. All we can do
+                       // is log the error in our own logs.
                        //
-                       // If headers have already been sent, the
-                       // client must notice the lack of trailing
+                       // The client must notice the lack of trailing
                        // newline as an indication that the response
                        // is incomplete.
-                       log.Printf("index error from volume %s: %s", v, err)
-                       http.Error(resp, "", http.StatusInternalServerError)
+                       ctxlog.FromContext(req.Context()).WithError(err).Errorf("truncating index response after error from volume %s", v)
                        return
                }
        }