Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 16 additions & 17 deletions cmd/topicctl/subcmd/rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,13 @@ func rebalanceRun(cmd *cobra.Command, args []string) error {
return err
}

existingConfigFiles := make(map[string]struct{})
bootstrappedFiles := make(map[string]struct{})
if rebalanceConfig.bootstrapMissingConfigs {
// make set of existing files
err := processTopicFiles(topicFiles, func(topicConfig config.TopicConfig, topicFile string) error {
// make set of existing files before bootstrapping
existingConfigFiles := make(map[string]struct{})
for _, topicFile := range topicFiles {
_, topicFilename := filepath.Split(topicFile)
existingConfigFiles[topicFilename] = struct{}{}
return nil
})
if err != nil {
return err
}

// bootstrap missing config files
Expand All @@ -188,6 +185,14 @@ func rebalanceRun(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

// make list of bootstrappedFiles
for _, topicFile := range topicFiles {
_, topicFilename := filepath.Split(topicFile)
if _, found := existingConfigFiles[topicFilename]; !found {
bootstrappedFiles[topicFile] = struct{}{}
}
}
}

// iterate through each topic config and initiate rebalance
Expand Down Expand Up @@ -264,16 +269,10 @@ func rebalanceRun(cmd *cobra.Command, args []string) error {
}

// clean up any bootstrapped topic configs
if rebalanceConfig.bootstrapMissingConfigs {
for _, topicFile := range topicFiles {
_, topicFilename := filepath.Split(topicFile)
if _, found := existingConfigFiles[topicFilename]; found {
continue
}
err := os.Remove(topicFile)
if err != nil {
log.Errorf("error deleting temporary file %s: %v", topicFile, err)
}
for topicFile := range bootstrappedFiles {
err := os.Remove(topicFile)
if err != nil {
log.Errorf("error deleting temporary file %s: %v", topicFile, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// Version is the current topicctl version.
const Version = "2.0.1"
const Version = "2.0.2"
Loading