Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the error messages on upload failures. #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improvements to the error messages on upload failures.
- Capture the HTTP status code on failure (esp. for uploads) and
  add it to the error accumulator.
- Use the error accumulator mechanism for uploads.
- Ensure that fatal upload failures aren't labelled retryable.
- When generating upload error messages, don't use the word "downloading"
bbockelm committed Jun 10, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
bbockelm Brian P Bockelman
commit 44e26f5fc3e1314eb5d1e8404034bcecfd2b0044
2 changes: 1 addition & 1 deletion cmd/stashcp/main.go
Original file line number Diff line number Diff line change
@@ -245,7 +245,7 @@ func main() {
if errMsg == "" {
errMsg = result.Error()
}
log.Errorln("Failure downloading " + lastSrc + ": " + errMsg)
log.Errorln("Failure transferring " + lastSrc + ": " + errMsg)
if stashcp.ErrorsRetryable() {
log.Errorln("Errors are retryable")
os.Exit(11)
12 changes: 12 additions & 0 deletions errorAccum.go
Original file line number Diff line number Diff line change
@@ -91,6 +91,18 @@ func IsRetryable(err error) bool {
}
return true
}
var hep *HttpErrResp
if errors.As(err, &hep) {
switch int(hep.Code) {
case http.StatusInternalServerError:
case http.StatusBadGateway:
case http.StatusServiceUnavailable:
case http.StatusGatewayTimeout:
return true
default:
return false
}
}
return false
}

16 changes: 14 additions & 2 deletions handle_http.go
Original file line number Diff line number Diff line change
@@ -39,6 +39,16 @@ func (e *StoppedTransferError) Error() string {
}


type HttpErrResp struct {
Code int
Err string
}

func (e *HttpErrResp) Error() string {
return e.Err
}


// SlowTransferError is an error that is returned when a transfer takes longer than the configured timeout
type SlowTransferError struct {
BytesTransferred int64
@@ -641,7 +651,8 @@ Loop:
// prior attempt.
if resp.HTTPResponse.StatusCode != 200 && resp.HTTPResponse.StatusCode != 206 {
log.Debugln("Got failure status code:", resp.HTTPResponse.StatusCode)
return 0, errors.New("failure status code")
return 0, &HttpErrResp{resp.HTTPResponse.StatusCode, fmt.Sprintf("Request failed (HTTP status %d): %s",
resp.HTTPResponse.StatusCode, resp.Err().Error())}
}
log.Debugln("HTTP Transfer was successful")
return resp.BytesComplete(), nil
@@ -760,7 +771,8 @@ Loop:
case response := <-responseChan:
if response.StatusCode != 200 {
log.Errorln("Got failure status code:", response.StatusCode)
lastError = errors.New("failure status code")
lastError = &HttpErrResp{response.StatusCode, fmt.Sprintf("Request failed (HTTP status %d)",
response.StatusCode)}
break Loop
}
break Loop
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -334,8 +334,12 @@ func DoStashCPSingle(sourceFile string, destination string, methods []string, re
ns, err := MatchNamespace(dest_url.Path)
if err != nil {
log.Errorln("Failed to get namespace information:", err)
AddError(err)
return 0, err
}
return doWriteBack(source_url.Path, dest_url, ns)
_, err = doWriteBack(source_url.Path, dest_url, ns)
AddError(err)
return 0, err
}

if dest_url.Scheme == "file" {