Skip to content

Commit

Permalink
Return ECANCELED when an op cancels its HTTP request due to interrupt
Browse files Browse the repository at this point in the history
In #288, multiple reports suggest that sometimes interrupts from unknown
source would cancel the ops running in Gcsfuse. While we currently
cannot identify those interrupts, it's possible to return a more
meaningful error code, ECANCELED, instead of ambiguous EIO, making debug
much easier.
  • Loading branch information
lezh committed Jun 7, 2021
1 parent ba90e59 commit 9c5da28
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/fs/wrappers/error_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"log"
"net/http"
"strings"
"syscall"

"github.com/googlecloudplatform/gcsfuse/internal/logger"
Expand All @@ -38,11 +39,16 @@ func errno(err error) error {
return errno
}

// em op is interrupted
// The fuse op is interrupted
if errors.Is(err, context.Canceled) {
return syscall.EINTR
}

// The HTTP request is canceled
if strings.Contains(err.Error(), "net/http: request canceled") {
return syscall.ECANCELED
}

// Translate API errors into an em errno
var apiErr *googleapi.Error
if errors.As(err, &apiErr) {
Expand Down

0 comments on commit 9c5da28

Please sign in to comment.