-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add --helm-debug
Flag to Kustomize for Enhanced Helm Debugging
#5751
Conversation
Hi @isarns. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there, @isarns! 👋🏻
Thanks for your PR! I left a few comments, mostly around testing. Could you please take a look at those?
@@ -174,7 +177,7 @@ func (p *HelmChartInflationGeneratorPlugin) runHelmCommand( | |||
fmt.Errorf( | |||
"unable to run: '%s %s' with env=%s (is '%s' installed?): %w", | |||
helm, strings.Join(args, " "), env, helm, err), | |||
stderr.String(), | |||
stderr.String()+stdout.String(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about the concatenation of the stdout
content here. What's the scenario this aims to address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helm --debug
write both to stderr (stack trace) and to stdout for the incomplete YAML template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Perhaps there would be value to adding a prefix so the user can identify which output is stdout
and which output is stderr
?
I am a bit concerned that this might become a wall of text difficult to parse through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an error format.
The output looks like that now:
Error: Helm stack trace:
install.go:218: [debug] Original chart version: ""
install.go:235: [debug] CHART PATH: /Users/isarn/temp/helm-debug
Error: YAML parse error on helm-debug/templates/test.yaml: error converting YAML to JSON: yaml: line 4: block sequence entries are not allowed in this context
helm.go:84: [debug] error converting YAML to JSON: yaml: line 4: block sequence entries are not allowed in this context
YAML parse error on helm-debug/templates/test.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:146
helm.sh/helm/v3/pkg/releaseutil.SortManifests
helm.sh/helm/v3/pkg/releaseutil/manifest_sorter.go:106
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
helm.sh/helm/v3/pkg/action/action.go:168
helm.sh/helm/v3/pkg/action.(*Install).RunWithContext
helm.sh/helm/v3/pkg/action/install.go:304
main.runInstall
helm.sh/helm/v3/cmd/helm/install.go:310
main.newTemplateCmd.func2
helm.sh/helm/v3/cmd/helm/template.go:95
github.com/spf13/cobra.(*Command).execute
github.com/spf13/[email protected]/command.go:983
github.com/spf13/cobra.(*Command).ExecuteC
github.com/spf13/[email protected]/command.go:1115
github.com/spf13/cobra.(*Command).Execute
github.com/spf13/[email protected]/command.go:1039
main.main
helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
runtime/proc.go:271
runtime.goexit
runtime/asm_amd64.s:1695
Helm template:
---
# Source: helm-debug/templates/test.yaml
---
apiVersion: test.kustomize.io/v1
kind: ValuesMergeTest
metadata:
name: -
: unable to run: 'helm template helm-debug-test /Users/isarn/temp/helm-debug -f /var/folders/6d/ck0zlsjx3vsd4x9r42y6knvr0000gn/T/kustomize-helm-194917191/helm-debug-kustomize-values.yaml --debug' with env=[HELM_CONFIG_HOME=/var/folders/6d/ck0zlsjx3vsd4x9r42y6knvr0000gn/T/kustomize-helm-194917191/helm HELM_CACHE_HOME=/var/folders/6d/ck0zlsjx3vsd4x9r42y6knvr0000gn/T/kustomize-helm-194917191/helm/.cache HELM_DATA_HOME=/var/folders/6d/ck0zlsjx3vsd4x9r42y6knvr0000gn/T/kustomize-helm-194917191/helm/.data] (is 'helm' installed?): exit status 1
plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go
Outdated
Show resolved
Hide resolved
This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/label tide/merge-method-squash |
Thanks @stormqueen1990!
Please let me know if there is anything else that needs to be done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/ok-to-test |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: isarns, koba1t The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [kubernetes-sigs/kustomize](https://github.com/kubernetes-sigs/kustomize) | minor | `v5.4.3` -> `v5.5.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>kubernetes-sigs/kustomize (kubernetes-sigs/kustomize)</summary> ### [`v5.5.0`](https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize/v5.5.0) [Compare Source](kubernetes-sigs/kustomize@kustomize/v5.4.3...kustomize/v5.5.0) ### Breaking change A starlark support for krm functions was removed to cleanup dependencies. kubernetes-sigs/kustomize#5768 This feature was deprecated 3 years ago and removed because there was no desire to continue using it. kubernetes-sigs/kustomize#5768 (comment) #### Feature [#​5751](kubernetes-sigs/kustomize#5751): Add `--helm-debug` Flag to Kustomize for Enhanced Helm Debugging #### Fix Bugs [#​5458](kubernetes-sigs/kustomize#5458): Sort built-in Namespace kind before CRDs with the same name [#​5745](kubernetes-sigs/kustomize#5745): Add Annotation to Control Inline List Conversion in Kustomize Resources" #### Dependencies [#​5763](kubernetes-sigs/kustomize#5763): Update go 1.22.7 [#​5781](kubernetes-sigs/kustomize#5781): Update kyaml to v0.18.1 [#​5782](kubernetes-sigs/kustomize#5782): Update cmd/config to v0.15.0 [#​5783](kubernetes-sigs/kustomize#5783): Update api to v0.18.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Summary of the Enhancement
This PR adds a new flag,
--helm-debug
, to the Kustomize CLI. When this flag is provided, the--debug
flag is passed to the Helm executable. This enables more detailed logging and error information from Helm, which is helpful when diagnosing issues with Helm charts during the Kustomize build process.Why This is Useful
In cases where Helm chart templates fail to render correctly, the default error messages can be opaque and difficult to diagnose. By enabling Helm’s
--debug
flag via--helm-debug
, users can see detailed logs from Helm, including the specific files and lines where errors occur, as well as the internal processes Helm is performing. This can save significant time in troubleshooting and resolving issues.Example Usage
Without
--helm-debug
:kustomize build . --load-restrictor=LoadRestrictionsNone --enable-helm
Output:
With
--helm-debug
:kustomize build . --load-restrictor=LoadRestrictionsNone --enable-helm --helm-debug
Output:
How to Test
--helm-debug
flag to your Kustomize command as shown above.Additional Notes
--helm-debug
flag is optional and can be omitted if detailed Helm debugging is not required.