Skip to content

Commit

Permalink
Fix nil deref if no upstreams available.
Browse files Browse the repository at this point in the history
  • Loading branch information
can1357 committed Mar 4, 2024
1 parent 67ca9d4 commit efb08ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func init() {

config.RootCommand.AddCommand(&cobra.Command{
Use: "go [manifest]",
Short: "Start the pmesh node with a manifest file",
Short: "Start the pmesh node with a manifest",
Args: cobra.MaximumNArgs(1),
GroupID: refGroup("daemon", "Daemon"),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
8 changes: 4 additions & 4 deletions lb/lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ func (lb *LoadBalancer) OnErrorResponse(ctx *requestContext, r *http.Response) h
// If we can retry:
if retryError := ctx.Retrier.ConsumeAny(); retryError == nil {
// Log and retry.
lb.getLogger().Warn().Str("status", r.Status).Str("upstream", ctx.Upstream.Address).Msg("retriable server error")
lb.getLogger().Warn().Str("status", r.Status).Stringer("upstream", ctx.Upstream).Msg("retriable server error")
return lbRetryHandler{ctx}
} else {
// Log.
lb.getLogger().Error().Str("status", r.Status).Err(retryError).Str("upstream", ctx.Upstream.Address).Msg("fatal server error")
lb.getLogger().Error().Str("status", r.Status).Err(retryError).Stringer("upstream", ctx.Upstream).Msg("fatal server error")
}
}
return nil
Expand All @@ -314,11 +314,11 @@ func (lb *LoadBalancer) OnError(ctx *requestContext, w http.ResponseWriter, r *h
// If we can retry:
if retryError := ctx.Retrier.Consume(err); retryError == nil {
// Log and retry.
lb.getLogger().Warn().Err(err).Str("upstream", ctx.Upstream.Address).Msg("retriable upstream error")
lb.getLogger().Warn().Err(err).Stringer("upstream", ctx.Upstream).Msg("retriable upstream error")
lb.serveHTTP(ctx, w, ctx.Request)
return
} else {
lb.getLogger().Error().Err(err).Str("upstream", ctx.Upstream.Address).Msg("fatal upstream error")
lb.getLogger().Error().Err(err).Stringer("upstream", ctx.Upstream).Msg("fatal upstream error")
}
vhttp.Error(w, ctx.Request, vhttp.StatusUpstreamError)
}
Expand Down

0 comments on commit efb08ff

Please sign in to comment.