Skip to content

Commit

Permalink
fix: Do correct check of num web addrs for LB
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Dec 30, 2024
1 parent 829c39f commit 130c54d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/lb/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ func (lb *CEEMSLoadBalancer) Main() error {
var (
webListenAddresses = lb.App.Flag(
"web.listen-address",
"Addresses on which to expose metrics and web interface.",
"Addresses on which to expose load balancer(s). When both TSDB and Pyroscope LBs are configured, it must be "+
"repeated to provide two addresses: one for TSDB LB and one for Pyroscope LB. In that case TSDB LB will listen on "+
"first address and Pyroscope LB on second address",
).Default(":9030", ":9040").Strings()
webConfigFile = lb.App.Flag(
"web.config.file",
Expand Down Expand Up @@ -253,7 +255,7 @@ func (lb *CEEMSLoadBalancer) Main() error {

// Ensure that enough web listen addresses are provided
webListenAddrs := *webListenAddresses
if len(lbTypes) != len(webListenAddrs) {
if len(lbTypes) > len(webListenAddrs) {
logger.Error("Missing web listen addresses", "num_lbs", len(lbTypes), "num_addrs", len(webListenAddrs))

return fmt.Errorf("insufficient --web.listen-address. Expected %d got %d", len(lbTypes), len(webListenAddrs))
Expand Down Expand Up @@ -309,14 +311,14 @@ func (lb *CEEMSLoadBalancer) Main() error {

rp := httputil.NewSingleHostReverseProxy(webURL)

backendServer, err := lb_backend.New(lbType, webURL, rp, logger)
backendServer, err := lb_backend.New(lbType, webURL, rp, logger.With("backend_type", lbType))
if err != nil {
logger.Error("Could not set up backend server", "backend_type", lbType, "err", errors.Unwrap(err))

continue
}

rp.ErrorHandler = frontend.ErrorHandler(webURL, backendServer, lbs[lbType], logger)
rp.ErrorHandler = frontend.ErrorHandler(webURL, backendServer, lbs[lbType], logger.With("backend_type", lbType))

managers[lbType].Add(backend.ID, backendServer)
}
Expand Down

0 comments on commit 130c54d

Please sign in to comment.