Skip to content

Commit

Permalink
fix error where confluent local couldn't work with newer docker deskt…
Browse files Browse the repository at this point in the history
…op versions (#2408)
  • Loading branch information
MuweiHe authored Nov 9, 2023
1 parent ddc4da4 commit 82cc2ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/local/command_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
const (
dockerImageName = "confluentinc/confluent-local:latest"
localhostPrefix = "http://localhost:%s"
localhost = "localhost"
localhost = "0.0.0.0"
kafkaRestNotReadySuggestion = "Kafka REST connection is not ready. Re-running the command may solve the issue."
)

Expand Down
11 changes: 6 additions & 5 deletions internal/local/command_kafka_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

const (
dockerWorkingVersionMsg = "This command has been verified to work with Docker v4.25.0. Verify that you are not using a newer, unverified version of Docker."
confluentBrokerPrefix = "confluent-local-broker-%d"
controllerVoterPrefix = "%d@confluent-local-broker-%d:%s"
bootstrapServerPrefix = "confluent-local-broker-%d:%s"
Expand Down Expand Up @@ -78,7 +79,7 @@ func (c *command) kafkaStart(cmd *cobra.Command, _ []string) error {

containers, err := dockerClient.ContainerList(context.Background(), types.ContainerListOptions{All: true})
if err != nil {
return err
return errors.NewErrorWithSuggestions(err.Error(), dockerWorkingVersionMsg)
}

for _, container := range containers {
Expand All @@ -105,7 +106,7 @@ func (c *command) kafkaStart(cmd *cobra.Command, _ []string) error {

out, err := dockerClient.ImagePull(context.Background(), dockerImageName, types.ImagePullOptions{})
if err != nil {
return err
return errors.NewErrorWithSuggestions(err.Error(), dockerWorkingVersionMsg)
}
defer out.Close()

Expand Down Expand Up @@ -161,7 +162,7 @@ func (c *command) kafkaStart(cmd *cobra.Command, _ []string) error {
Driver: "bridge",
}
if _, err := dockerClient.NetworkCreate(context.Background(), confluentLocalNetworkName, options); err != nil && !strings.Contains(err.Error(), "already exists") {
return err
return errors.NewErrorWithSuggestions(err.Error(), dockerWorkingVersionMsg)
}

var containerIds []string
Expand Down Expand Up @@ -194,11 +195,11 @@ func (c *command) kafkaStart(cmd *cobra.Command, _ []string) error {

createResp, err := dockerClient.ContainerCreate(context.Background(), config, hostConfig, nil, platform, fmt.Sprintf(confluentBrokerPrefix, brokerId))
if err != nil {
return err
return errors.NewErrorWithSuggestions(err.Error(), dockerWorkingVersionMsg)
}
log.CliLogger.Trace(fmt.Sprintf("Successfully created a Confluent Local container for broker %d", brokerId))
if err := dockerClient.ContainerStart(context.Background(), createResp.ID, types.ContainerStartOptions{}); err != nil {
return err
return errors.NewErrorWithSuggestions(err.Error(), dockerWorkingVersionMsg)
}
containerIds = append(containerIds, getShortenedContainerId(createResp.ID))
}
Expand Down

0 comments on commit 82cc2ba

Please sign in to comment.