Skip to content

Commit

Permalink
Captures helm error before trying to call WaitForReadyLoftPod
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbitx committed Sep 16, 2024
1 parent 6143e22 commit b858313
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/vclusterctl/cmd/platform/add/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit b858313

Please sign in to comment.