Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kafka: manager: List topics before creating them #316

Merged
merged 6 commits into from
Oct 31, 2023

Conversation

marclop
Copy link
Contributor

@marclop marclop commented Oct 30, 2023

Updates the manager CreateTopics method to only issue the CreateTopics call if the topics don't exist in Kafka, preventing undesirable errors from being returned and logged.

Updates the manager `CreateTopics` method to only issue the CreateTopics
call if the topics don't exist in Kafka, preventing undesirable errors
from being returned and logged.

Signed-off-by: Marc Lopez Rubio <[email protected]>
@marclop marclop requested a review from a team October 30, 2023 06:16
kafka/topiccreator.go Outdated Show resolved Hide resolved
alterCfg = append(alterCfg, kadm.AlterConfig{Name: k, Value: v})
}
alterResp, err := c.m.adminClient.AlterTopicConfigs(ctx,
alterCfg, topicNames...,
Copy link
Member

Choose a reason for hiding this comment

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

Should we only be altering topic configs for topics that we didn't just create? We'll get a lot of log spam otherwise won't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, I didn't as to decouple the two... But I suppose we can. I can change it if you think it's significantly better. If it's just due to the logging, we could consolidate the info logging to a single line and use a topic slice instead of a single log line per topic altered.

Copy link
Member

Choose a reason for hiding this comment

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

Even if it's one log line vs. N, I'd rather not see an Info log every time this function is called if it's effectively a no-op. That aside, it would be good to minimise the number of network calls - that's a smaller issue though, considering how infrequently this should be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the code and the test a bit in 8acf0af. Let me know what you think.

Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
axw
axw previously approved these changes Oct 31, 2023
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

kafka/topiccreator.go Outdated Show resolved Hide resolved
Co-authored-by: Andrew Wilkins <[email protected]>
axw
axw previously approved these changes Oct 31, 2023
@marclop
Copy link
Contributor Author

marclop commented Oct 31, 2023

I've opened #318 to investigate.

@marclop marclop merged commit f628323 into main Oct 31, 2023
8 checks passed
@marclop marclop deleted the f/list-topics-before-creating-them branch October 31, 2023 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants