Skip to content

Commit

Permalink
distinguish 502 from 503 errors in ping handler for error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyzags committed Jan 27, 2025
1 parent 446fcd1 commit 6cf947b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/relayer/relayminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"net/http"
"net/http/pprof"
"net/url"

"cosmossdk.io/depinject"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -168,7 +169,12 @@ func (rel *relayMiner) newPinghandlerFn(ctx context.Context, ln net.Listener) ht
rel.logger.Debug().Msg("pinging relay servers...")

if err := rel.relayerProxy.PingAll(ctx); err != nil {
w.WriteHeader(http.StatusBadGateway)
var urlError url.Error
if errors.As(err, &urlError) && urlError.Temporary() {
w.WriteHeader(http.StatusGatewayTimeout)
} else {
w.WriteHeader(http.StatusBadGateway)
}
return
}

Expand Down

0 comments on commit 6cf947b

Please sign in to comment.