segmentio / topicctl

Tool for declarative management of Kafka topics
MIT License
579 stars 54 forks source link

subcmd/apply: Support fail-safe approach #185

Closed shimon-armis closed 3 months ago

shimon-armis commented 3 months ago

Description

Up until now, the apply command implemented a fail-fast strategy. This means that an attempt to configure a batch of topics (by passing a path to a folder contains a list of topics configurations files) will be terminated upon the first failure (w/o even trying to apply the configuration for the next-in-line topics). This commit introduces the fail-safe support: It allows the user to run the apply command in a fail-safe manner, which means that instead of failing upon the first failure, we'll simply continue to the next topic configuration, while aggregating all the errors along the way. Eventually, if there were any errors, all of them will be shown.

shimon-armis commented 3 months ago

@hhahn-tw Can you please review this one? :)

shimon-armis commented 3 months ago

@hhahn-tw @petedannemann Can you guys maybe take a look?

shimon-armis commented 3 months ago

@jkoelker Can you maybe review this PR?

shimon-armis commented 3 months ago

LGTM, just a reccomendation to use errors.Join to concat the errors, if not, you can also use fmt.Errorf with multiple %w to achieve the same thing and not drop the error context by rendering it as a string.

errors.Join() is only supported from go 1.20 (this repo is running v1.18). Also, fmt.Errorf() doesn't support multiple %w (as explained here. Here's the error I got in the PR check: Error: cmd/topicctl/subcmd/apply.go:182:12: fmt.Errorf call has more than one error-wrapping directive %w make: *** [Makefile:20: vet] Error 1

shimon-armis commented 3 months ago

@hhahn-tw Can you please merge this one?

shimon-armis commented 3 months ago

@hhahn-tw ?

hhahn-tw commented 3 months ago

Thanks once more for your contribution!