Move error logging for block-not-found from GetBlock to GetBlockHandler.
authorWard Vandewege <ward@curoverse.com>
Wed, 2 Jul 2014 01:27:34 +0000 (21:27 -0400)
committerWard Vandewege <ward@curoverse.com>
Wed, 2 Jul 2014 01:48:17 +0000 (21:48 -0400)
It doesn't belong in GetBlock because GetBlock is also called from
PutBlock, which checks to see if a block exists before it writes it
again.

In other words, in the most common scenario (a PUT of a new block), Keep
should not print a bogus error message.

services/keep/src/keep/keep.go

index 429a7e01b29b517e8757427412654e0d18dada67..7d86202301ce27337c1076e8c89e4ccb72c7c90b 100644 (file)
@@ -413,6 +413,9 @@ func GetBlockHandler(resp http.ResponseWriter, req *http.Request) {
        if err != nil {
                // This type assertion is safe because the only errors
                // GetBlock can return are CorruptError or NotFoundError.
+               if err == NotFoundError {
+                       log.Printf("%s: not found, giving up\n", hash)
+               }
                http.Error(resp, err.Error(), err.(*KeepError).HTTPCode)
                return
        }
@@ -601,7 +604,6 @@ func GetBlock(hash string) ([]byte, error) {
                }
        }
 
-       log.Printf("%s: not found on any volumes, giving up\n", hash)
        return nil, NotFoundError
 }