From beb2213998e62658ae5ed523813b96a087aef5e9 Mon Sep 17 00:00:00 2001 From: Ben McKerry <110857332+bmckerry@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:43:40 -0400 Subject: [PATCH] chore: better logging on assignment errors --- pkg/apply/assigners/evaluate.go | 5 +++++ pkg/apply/rebalancers/frequency.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/apply/assigners/evaluate.go b/pkg/apply/assigners/evaluate.go index 36f90e74..88e3e4b1 100644 --- a/pkg/apply/assigners/evaluate.go +++ b/pkg/apply/assigners/evaluate.go @@ -6,6 +6,7 @@ import ( "github.com/segmentio/topicctl/pkg/admin" "github.com/segmentio/topicctl/pkg/config" + log "github.com/sirupsen/logrus" ) // EvaluateAssignments determines whether the given assignments are consistent @@ -61,6 +62,10 @@ func EvaluateAssignments( brokerRacks := admin.BrokerRacks(brokers) for _, assignment := range assignments { if len(assignment.Replicas) != len(assignment.DistinctRacks(brokerRacks)) { + log.Errorf( + "Expected replicas to equal number of racks, but got %d replicas and %d racks for assignment %v", + len(assignment.Replicas), len(assignment.DistinctRacks(brokerRacks)), assignment, + ) return false, nil } } diff --git a/pkg/apply/rebalancers/frequency.go b/pkg/apply/rebalancers/frequency.go index 142e6501..bda4e91b 100644 --- a/pkg/apply/rebalancers/frequency.go +++ b/pkg/apply/rebalancers/frequency.go @@ -67,7 +67,7 @@ func (f *FrequencyRebalancer) Rebalance( if err != nil { return nil, err } else if !ok { - return nil, fmt.Errorf("Starting assignments do not satisfy placement config") + return nil, fmt.Errorf("starting assignments on topic %s do not satisfy placement config - assignments: %#v", topic, curr) } desired := admin.CopyAssignments(curr)