diff --git a/cmd/vclusterctl/cmd/platform/add/cluster.go b/cmd/vclusterctl/cmd/platform/add/cluster.go index 0542e115c..5055c8e7d 100644 --- a/cmd/vclusterctl/cmd/platform/add/cluster.go +++ b/cmd/vclusterctl/cmd/platform/add/cluster.go @@ -223,6 +223,8 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error { errChan := make(chan error) go func() { + defer close(errChan) + helmCmd := exec.CommandContext(ctx, "helm", helmArgs...) helmCmd.Stdout = cmd.Log.Writer(logrus.DebugLevel, true) @@ -235,14 +237,18 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error { err = helmCmd.Run() if err != nil { errChan <- fmt.Errorf("failed to install loft chart: %w", err) + return } - close(errChan) + _, err = clihelper.WaitForReadyLoftPod(ctx, clientset, namespace, cmd.Log) + if err != nil { + errChan <- fmt.Errorf("wait for loft pod: %w", err) + return + } }() - _, err = clihelper.WaitForReadyLoftPod(ctx, clientset, namespace, cmd.Log) - if err = errors.Join(err, <-errChan); err != nil { - return fmt.Errorf("wait for loft pod: %w", err) + if err = errors.Join(<-errChan); err != nil { + return err } if cmd.Wait {