From efb08ff68acadde47a1f396cbe257ff5605dfc90 Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 4 Mar 2024 18:01:54 +0100 Subject: [PATCH] Fix nil deref if no upstreams available. --- cmd/start.go | 2 +- lb/lb.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index bac12c8..c847671 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -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) { diff --git a/lb/lb.go b/lb/lb.go index 4f21021..e1c9df7 100644 --- a/lb/lb.go +++ b/lb/lb.go @@ -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 @@ -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) }