Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#144 from jhiemstrawisc/improve-err…
Browse files Browse the repository at this point in the history
…-msgs

Incorporate PR PelicanPlatform#78 from old osdf-client
  • Loading branch information
jhiemstrawisc authored Sep 22, 2023
2 parents ae47221 + db8f4d0 commit a6fc00c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/object_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func copyMain(cmd *cobra.Command, args []string) {
if errMsg == "" {
errMsg = result.Error()
}
log.Errorln("Failure downloading " + lastSrc + ": " + errMsg)
log.Errorln("Failure transferring " + lastSrc + ": " + errMsg)
if pelican.ErrorsRetryable() {
log.Errorln("Errors are retryable")
os.Exit(11)
Expand Down
12 changes: 12 additions & 0 deletions errorAccum.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,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
}

Expand Down
6 changes: 4 additions & 2 deletions handle_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,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
Expand Down Expand Up @@ -808,7 +809,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
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,12 @@ func DoStashCPSingle(sourceFile string, destination string, methods []string, re
ns, err := namespaces.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" {
Expand Down

0 comments on commit a6fc00c

Please sign in to comment.