Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/apply/rebalancers/frequency.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/segmentio/topicctl/pkg/apply/assigners"
"github.com/segmentio/topicctl/pkg/apply/pickers"
"github.com/segmentio/topicctl/pkg/config"
log "github.com/sirupsen/logrus"
)

// FrequencyRebalancer is a Rebalancer that rebalances to achieve in-topic balance among
Expand Down Expand Up @@ -67,7 +68,13 @@ func (f *FrequencyRebalancer) Rebalance(
if err != nil {
return nil, err
} else if !ok {
return nil, fmt.Errorf("starting assignments on topic %s do not satisfy placement config - assignments: %#v", topic, curr)
// If we're doing a static rebalance, we don't expect the existing assignments to
// satify the placement config
if f.placementConfig.Strategy == config.PlacementStrategyStatic {
log.Info("Current partition assignment does not match static assignment, rebalancing will take place")
} else {
Comment on lines +72 to +75
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When applying a new topic, if EvaluateAssignments returns false, topicctl knows it needs to adjust the partition placement of the new topic to match the desired placement strategy: https://github.com/getsentry/topicctl/blob/master/pkg/apply/apply.go#L831

When rebalancing a topic (which is what this frequency.go file is used for), if EvaluateAssignments returns false, topicctl considers that to be an error. I've updated it so that if we're using static placement, topicctl doesn't error out here when rebalancing.

return nil, fmt.Errorf("starting assignments on topic %s do not satisfy placement config - assignments: %#v", topic, curr)
}
}

desired := admin.CopyAssignments(curr)
Expand Down