Skip to content

Commit

Permalink
Add altertopicpartitions error handler (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
pecigonzalo committed Feb 23, 2023
1 parent 7d30f24 commit 342c7c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/admin/brokerclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ func (c *BrokerAdminClient) AssignPartitions(
if err = resp.Error; err != nil {
return err
}
if err = util.AlterPartitionReassignmentsRequestAssignmentError(resp.PartitionResults); err != nil {
return err
}

return err
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/util/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@ func IncrementalAlterConfigsResponseResourcesError(resources []kafka.Incremental
}
return nil
}

func AlterPartitionReassignmentsRequestAssignmentError(results []kafka.AlterPartitionReassignmentsResponsePartitionResult) error {
errors := map[int]error{}
var hasErrors bool
for _, result := range results {
if result.Error != nil {
hasErrors = true
errors[result.PartitionID] = result.Error
}
}
if hasErrors {
return fmt.Errorf("%+v", errors)
}
return nil
}

0 comments on commit 342c7c3

Please sign in to comment.