Skip to content

Commit

Permalink
Merge pull request #129 from Scandiravian/handle_UnknownTopicOrPartit…
Browse files Browse the repository at this point in the history
…ion_error

Create topic instead of panic, when error is UnknownTopicOrPartition
  • Loading branch information
weeco authored Nov 3, 2021
2 parents 9162d2f + 776cc2d commit 9960755
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions e2e/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func (s *Service) validateManagementTopic(ctx context.Context) error {
return fmt.Errorf("validateManagementTopic cannot get metadata of e2e topic: %w", err)
}

topicExists := false
if len(meta.Topics) == 1 {
err := kerr.ErrorForCode(meta.Topics[0].ErrorCode)
if err != nil {
return fmt.Errorf("failed to get metadata for end-to-end topic: %w", err)
}

topicExists = true
// UnknownTopicOrPartition (Error code 3) means that the topic does not exist.
// If the topic exists, but there's an error, then this should result in a fail
// When the topic doesn't exist, continue to create it
err = kerr.TypedErrorForCode(meta.Topics[0].ErrorCode)
topicExists := err != kerr.UnknownTopicOrPartition

if err != nil && topicExists {
return fmt.Errorf("failed to get metadata for end-to-end topic: %w", err)
}

// Create topic if it doesn't exist
Expand Down

0 comments on commit 9960755

Please sign in to comment.