Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captures helm error before trying to call WaitForReadyLoftPod #2148

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
29 changes: 11 additions & 18 deletions cmd/vclusterctl/cmd/platform/add/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package add
import (
"cmp"
"context"
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -220,28 +219,22 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error {
return fmt.Errorf("create kube client: %w", err)
}

errChan := make(chan error)
helmCmd := exec.CommandContext(ctx, "helm", helmArgs...)

go func() {
helmCmd := exec.CommandContext(ctx, "helm", helmArgs...)
helmCmd.Stdout = cmd.Log.Writer(logrus.DebugLevel, true)
helmCmd.Stderr = cmd.Log.Writer(logrus.DebugLevel, true)
helmCmd.Stdin = os.Stdin

helmCmd.Stdout = cmd.Log.Writer(logrus.DebugLevel, true)
helmCmd.Stderr = cmd.Log.Writer(logrus.DebugLevel, true)
helmCmd.Stdin = os.Stdin
cmd.Log.Info("Installing Loft agent...")
cmd.Log.Debugf("Running helm command: %v", helmCmd.Args)

cmd.Log.Info("Installing Loft agent...")
cmd.Log.Debugf("Running helm command: %v", helmCmd.Args)

err = helmCmd.Run()
if err != nil {
errChan <- fmt.Errorf("failed to install loft chart: %w", err)
}

close(errChan)
}()
err = helmCmd.Run()
if err != nil {
return fmt.Errorf("failed to install loft chart: %w", err)
}

_, err = clihelper.WaitForReadyLoftPod(ctx, clientset, namespace, cmd.Log)
if err = errors.Join(err, <-errChan); err != nil {
if err != nil {
return fmt.Errorf("wait for loft pod: %w", err)
}

Expand Down
Loading