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
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/cli/container/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
var (
tag = "latest"
redpandaImageBase = "redpandadata/redpanda:" + tag
consoleImageBase = "redpandadata/console:latest"
consoleImageBase = "redpandadata/console:v2.8.5"
)

const (
Expand Down
42 changes: 32 additions & 10 deletions src/go/rpk/pkg/cli/container/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,30 @@ func startCluster(
fmt.Println("Waiting for the cluster to be ready...")
err = waitForCluster(check(nodes), retries)
if err != nil {
state, sErr := common.GetState(c, nodes[0].id, false)
if sErr != nil {
return false, fmt.Errorf("%v\nunable to get Docker container logs: %v", err, sErr)
var failedNodeState *common.NodeState
for _, n := range nodes {
state, sErr := common.GetState(c, n.id, false)
if sErr != nil {
return false, fmt.Errorf("%v\nunable to get Docker container (%v) logs: %v", n.id, err, sErr)
}
if !state.Running {
failedNodeState = state
}
}
errStr, cErr := getContainerErr(state, c)
// Sanity check: If the cluster didn't start but all the containers are
// running. Maybe the cluster is not ready yet and the user needs to
// increase the retries.
if failedNodeState == nil {
return false, fmt.Errorf("unable to start the cluster on time: %v; you may run 'rpk container purge' and start again increasing the number of retries with the '--retries' flag", err)
}

errStr, cErr := getContainerErr(failedNodeState, c)
if cErr != nil {
return false, fmt.Errorf("%v\nunable to get Docker container logs: %v", err, cErr)
}
return false, fmt.Errorf("%v\n\nErrors reported from the Docker container:\n\n%v", err, errStr)
// Docker usually truncates the container ID to 12 characters.
shortID := fmt.Sprintf("%.*s", 12, failedNodeState.ContainerID)
return false, fmt.Errorf("%v\n\nErrors reported from the Docker container with ID %v:\n\n%v", err, shortID, errStr)
}
fmt.Println("Cluster ready!")

Expand Down Expand Up @@ -443,6 +458,10 @@ func restartCluster(
if len(states) == 0 {
return nil, nil
}
// If we only have one stranded Console container, the user must purge it.
if len(states) == 1 && states[0].Console {
return nil, fmt.Errorf("stranded Redpanda Console container detected; please run 'rpk container purge' and try again")
}
grp, _ := errgroup.WithContext(context.Background())
mu := sync.Mutex{}
var (
Expand Down Expand Up @@ -496,7 +515,7 @@ func restartCluster(
return nil, fmt.Errorf("%v\n\nErrors reported from the Docker container:\n%v", err, errStr)
}

if !consoleState.Running {
if consoleState != nil && !consoleState.Running {
ctx, _ := common.DefaultCtx()
err = c.ContainerStart(ctx, consoleState.ContainerID, container.StartOptions{})
if err != nil {
Expand All @@ -510,11 +529,14 @@ func restartCluster(
}
err = waitForCluster(checkConsole(consoleNode), retries)
if err != nil {
errStr, cErr := getContainerErr(consoleState, c)
if cErr != nil {
return nil, fmt.Errorf("%v\nunable to get Docker container logs: %v", err, cErr)
if consoleState != nil {
errStr, cErr := getContainerErr(consoleState, c)
if cErr != nil {
return nil, fmt.Errorf("%v\nunable to get Docker container logs: %v", err, cErr)
}
return nil, fmt.Errorf("%v\n\nErrors reported from the Docker container:\n%v", err, errStr)
}
return nil, fmt.Errorf("%v\n\nErrors reported from the Docker container:\n%v", err, errStr)
return nil, fmt.Errorf("error restarting the console cluster: %v; you may run 'rpk container purge' and start again", err)
}
return rpNodes, nil
}
Expand Down