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

Presence of HELM_HOME environment variable causes Helm v3 command to fail #1070

Closed
kahkeng opened this issue Apr 15, 2020 · 1 comment · Fixed by #1076
Closed

Presence of HELM_HOME environment variable causes Helm v3 command to fail #1070

kahkeng opened this issue Apr 15, 2020 · 1 comment · Fixed by #1076
Assignees
Milestone

Comments

@kahkeng
Copy link

kahkeng commented Apr 15, 2020

Problem description

With the Helm v3 binary, it seems --home is no longer a valid flag, so the presence of HELM_HOME environment variable will cause helm fetch commands to fail with an unclear error message, when they previously would work with the Helm v2 binary. This affects users of the Pulumi docker images that previously had Helm v2 but are now shipping with Helm v3 by default (since pulumi/pulumi#4090).

Errors & Logs

The error looks like this, if the HELM_HOME environment variable exists:

2020-04-15T00:15:19.5419814Z Diagnostics:
2020-04-15T00:15:19.5420479Z   pulumi:pulumi:Stack (clusterServices-utils):
2020-04-15T00:15:19.5421018Z     error: Program failed with an unhandled exception:
2020-04-15T00:15:19.5421552Z     error: Traceback (most recent call last):
2020-04-15T00:15:19.5422423Z       File "/usr/bin/pulumi-language-python-exec", line 85, in <module>
2020-04-15T00:15:19.5423018Z         loop.run_until_complete(coro)
2020-04-15T00:15:19.5423601Z       File "/usr/local/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
2020-04-15T00:15:19.5424173Z         return future.result()
2020-04-15T00:15:19.5424894Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 81, in run_in_stack
2020-04-15T00:15:19.5425502Z         await run_pulumi_func(lambda: Stack(func))
2020-04-15T00:15:19.5426252Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 50, in run_pulumi_func
2020-04-15T00:15:19.5426850Z         await RPC_MANAGER.rpcs.pop()
2020-04-15T00:15:19.5427606Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
2020-04-15T00:15:19.5428188Z         result = await rpc
2020-04-15T00:15:19.5428922Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/resource.py", line 440, in do_register_resource_outputs
2020-04-15T00:15:19.5429560Z         serialized_props = await rpc.serialize_properties(outputs, {})
2020-04-15T00:15:19.5430355Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 68, in serialize_properties
2020-04-15T00:15:19.5431151Z         result = await serialize_property(v, deps, input_transformer)
2020-04-15T00:15:19.5432064Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 173, in serialize_property
2020-04-15T00:15:19.5433311Z         value = await serialize_property(output.future(), deps, input_transformer)
2020-04-15T00:15:19.5434624Z       File "/usr/local/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 159, in serialize_property
2020-04-15T00:15:19.5435457Z         future_return = await asyncio.ensure_future(awaitable)
2020-04-15T00:15:19.5436506Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 114, in get_value
2020-04-15T00:15:19.5437304Z         val = await self._future
2020-04-15T00:15:19.5438266Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
2020-04-15T00:15:19.5439079Z         value = await self._future
2020-04-15T00:15:19.5440040Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
2020-04-15T00:15:19.5440820Z         value = await self._future
2020-04-15T00:15:19.5441793Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
2020-04-15T00:15:19.5442575Z         value = await self._future
2020-04-15T00:15:19.5443271Z       [Previous line repeated 3 more times]
2020-04-15T00:15:19.5444263Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 186, in run
2020-04-15T00:15:19.5445064Z         return await transformed.future(with_unknowns=True)
2020-04-15T00:15:19.5446107Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 114, in get_value
2020-04-15T00:15:19.5446913Z         val = await self._future
2020-04-15T00:15:19.5447870Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
2020-04-15T00:15:19.5448673Z         value = await self._future
2020-04-15T00:15:19.5463192Z       File "/usr/local/lib/python3.7/site-packages/pulumi/output.py", line 176, in run
2020-04-15T00:15:19.5464048Z         transformed: Input[U] = func(value)
2020-04-15T00:15:19.5465146Z       File "/usr/local/lib/python3.7/site-packages/pulumi_kubernetes/helm/v2/helm.py", line 325, in _parse_chart
2020-04-15T00:15:19.5466062Z         _fetch(chart_to_fetch, fetch_opts)
2020-04-15T00:15:19.5467156Z       File "/usr/local/lib/python3.7/site-packages/pulumi_kubernetes/helm/v2/helm.py", line 407, in _fetch
2020-04-15T00:15:19.5468148Z         subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True)
2020-04-15T00:15:19.5469024Z       File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
2020-04-15T00:15:19.5469809Z         output=stdout, stderr=stderr)
2020-04-15T00:15:19.5471305Z     subprocess.CalledProcessError: Command '['helm', 'fetch', 'stable/wordpress', '--untar', '--home', '/root/.helm', '--version', '2.1.3', '--destination', '/tmp/tmp9q63lhrf']' returned non-zero exit status 1.
2020-04-15T00:15:19.5472422Z     error: an unhandled error occurred: Program exited with non-zero exit code: 1

Affected product version(s)

I'm using pulumi 1.14.0 and pulumi_kubernetes 1.6.0 on python SDK, and Pulumi action's latest docker image.

Reproducing the issue

This script to install a Helm chart modified from https://www.pulumi.com/docs/guides/adopting/from_kubernetes/ to use helm.v3 would reproduce the above.

import pulumi
from pulumi_kubernetes.helm.v3 import Chart, ChartOpts

# Deploy the latest version of the stable/wordpress chart.
wordpress = Chart('wpdev', config=ChartOpts(
    repo='stable',
    chart='wordpress',
    version='2.1.3',
))

Suggestions for a fix

It might be helpful to warn or throw a clearer assertion error if HELM_HOME is specified when helm.v3 is being used. Or ignore HELM_HOME altogether and not produce the --home argument in the helm.v3 module, so that the fetch is still attempted with the default config/cache paths.

For those who need the ability to specify a different helm home directory, it seems the recommended way to override this path in Helm v3 is to use the following environment variables now (based on https://helm.sh/docs/faq/#xdg-base-directory-support):

XDG_CONFIG_HOME=$HOME/.config
XDG_CACHE_HOME=$HOME/.cache

I'm not sure the best way to achieve this now in the helm.v3 module in lieu of using the FetchOpts.home param, but it seems like any use of this param right now will fail with Helm v3 in a similar manner to above (due to --home not being a valid flag for helm v3).

(FWIW, I filed a related issue to suggest adding these environment variable definitions by default to the Pulumi docker images: pulumi/pulumi#4397)

@kahkeng
Copy link
Author

kahkeng commented Apr 22, 2020

Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants