Skip to content

specifying Helm version doesn't seem to be used in plan-preview #5635

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

Closed
JohnTitor opened this issue Mar 7, 2025 · 3 comments · Fixed by #5636
Closed

specifying Helm version doesn't seem to be used in plan-preview #5635

JohnTitor opened this issue Mar 7, 2025 · 3 comments · Fixed by #5636
Labels
kind/bug Something isn't working as expected

Comments

@JohnTitor
Copy link
Contributor

What happened:
plan-preview currently fails if we use config/templates described in the "How to reproduce it" section.

The error itself is:

Reason: failed while planning, unable to run kustomize template: exit status 1: Error: Error: template: datadog/templates/gke_autopilot_allowlist_synchronizer.yaml:1:48: executing "datadog/templates/gke_autopilot_allowlist_synchronizer.yaml" at <include "gke-autopilot-workloadallowlists-enabled" .>: error calling include: template: datadog/templates/_helpers.tpl:74:23: executing "gke-autopilot-workloadallowlists-enabled" at <len $nodes>: error calling len: reflect: call of reflect.Value.Type on zero Value

This is caused by older Helm, like v3.8.0. Helm v3.17.0, for instance, treats it without any failure.

The mysterious part of this problem is it still occurs even if we have a config like helmVersion: 3.17.0 in pipecd.yaml. We thought it was used in plan-preview.

I thought #4382 fixed the problem but for some reason our plan preview is still broken. Maybe we've misconfigured something or implementation still needs a tweak.

(note: we haven't checked if this problem only occur on plan-preview or not.)

What you expected to happen: should succeed plan-preview (and any other procedure)

How to reproduce it:

  1. prepare a PipeCD config like:
apiVersion: pipecd.dev/v1beta1
kind: KubernetesApp
spec:
name: datadog-agent
input:
  kustomizeVersion: 5.6.0
  kustomizeOptions:
    enable-helm: ""
  helmVersion: 3.17.0
  1. prepare a Kustomize config like:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmCharts:
  - name: datadog
    releaseName: datadog-agent
    repo: https://helm.datadoghq.com
    version: 3.102.0
  1. Run pipectl plan-preview or trigger the plan-preview action against it

Environment:

  • piped version: v0.50.2
  • control-plane version: v0.50.2
  • Others:
    • datadog-agent chart: v3.98.0 or higher
    • Kustomize: v5.6.0
    • Helm: v3.17.0
@JohnTitor JohnTitor added the kind/bug Something isn't working as expected label Mar 7, 2025
@Warashi
Copy link
Member

Warashi commented Mar 7, 2025

We have to pass the helm command path with the --helm-command option when executing kustomize, but the current implementation doesn't seem to do that.
https://kubernetes.io/docs/reference/kubectl/generated/kubectl_kustomize/#options

func (c *Kustomize) Template(ctx context.Context, appName, appDir string, opts map[string]string) (string, error) {
args := []string{
"build",
".",
}
for k, v := range opts {
args = append(args, fmt.Sprintf("--%s", k))
if v != "" {
args = append(args, v)
}
}
var stdout, stderr bytes.Buffer
cmd := exec.CommandContext(ctx, c.execPath, args...)
cmd.Dir = appDir
cmd.Stdout = &stdout
cmd.Stderr = &stderr
c.logger.Info(fmt.Sprintf("start templating a Kustomize application %s", appName),
zap.Any("args", args),
)
if err := cmd.Run(); err != nil {
return stdout.String(), fmt.Errorf("%w: %s", err, stderr.String())
}
return stdout.String(), nil
}

@Warashi
Copy link
Member

Warashi commented Mar 7, 2025

@JohnTitor
Thanks for raising this issue.
If you have time, would you be able to help resolve this issue?
You can refer to this method for finding the helm command path:

func (l *loader) findHelm(ctx context.Context, version string) (*Helm, error) {
path, installed, err := toolregistry.DefaultRegistry().Helm(ctx, version)
if err != nil {
return nil, fmt.Errorf("no helm %s (%v)", version, err)
}
if installed {
l.logger.Info(fmt.Sprintf("helm %s has just been installed because of no pre-installed binary for that version", version))
}
return NewHelm(version, path, l.logger), nil
}

@JohnTitor
Copy link
Contributor Author

Sure, let me take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants