-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Chart v4 fails on update (#3046)
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md) for Pulumi's contribution guidelines. Help us merge your changes more quickly by adding more details such as labels, milestones, and reviewers.--> ### Proposed changes <!--Give us a brief description of what you've done and what it solves. --> This PR fixes a problem with how Chart v4 uses the Helm library. The design goal is to allow for connectivity during template rendering, to support the lookup function (see helm/helm#9426) and to provide an accurate [Capabilities object](https://helm.sh/docs/chart_template_guide/builtin_objects/). Unfortunately we were slightly too aggressive and caused some of Helm's "non-template" code to execute. This fix works by turning off the `helm template --validation` flag, so that the internal `ClientOnly` flag is true thus avoiding [this block of code](https://github.com/helm/helm/blob/6f32a8f9d338bacc3c6a1c0c3610012b01edb3d1/pkg/action/install.go#L345-L350) that causes the unexpected error. A side-effect of `ClientOnly` being true is that the capabilities aren't automatically set, and so we set them using the provider's kube client (akin to using `--kube-version`). Detailed changes: - (chart.go) use ClientOnly mode, set KubeVersion and APIVersions - (tool.go) remove redundant KubeVersion and ExtraAPIs - (testdata/reference) add a version check - (chart_test.go) unit tests for `.Capabilities` - integration test to install cert-manager ### Related issues (optional) <!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes #1234'. Or link to full URLs to issues or pull requests in other GitHub repositories. --> Closes #3045
- Loading branch information
1 parent
4fddc20
commit 1100978
Showing
9 changed files
with
110 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
provider/pkg/provider/helm/v4/testdata/reference/templates/versioncheck.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{{- if .Values.versionCheck -}} | ||
{{- if semverCompare .Values.versionCheck .Capabilities.KubeVersion.GitVersion -}} | ||
{{- if not (semverCompare .Values.versionCheck .Capabilities.KubeVersion.GitVersion) -}} | ||
{{ fail "Version check failed" }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pulumi/providertest/pulumitest" | ||
"github.com/pulumi/pulumi/sdk/v3/go/auto/optup" | ||
) | ||
|
||
// TestChartV4 deploys a complex stack using chart/v4 package. | ||
func TestChartv4(t *testing.T) { | ||
test := pulumitest.NewPulumiTest(t, "testdata/chartv4") | ||
t.Logf("into %s", test.Source()) | ||
t.Cleanup(func() { | ||
test.Destroy() | ||
}) | ||
test.Preview() | ||
test.Up() | ||
test.Up(optup.ExpectNoChanges()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: chartv4 | ||
runtime: yaml | ||
description: | | ||
Installs cert-manager using Helm Chart v4 resource. | ||
Features used: | ||
- Chart resource | ||
variables: {} | ||
outputs: | ||
resources: ${install.resources} | ||
resources: | ||
ns: | ||
type: kubernetes:core/v1:Namespace | ||
install: | ||
type: kubernetes:helm.sh/v4:Chart | ||
properties: | ||
namespace: ${ns.metadata.name} | ||
chart: oci://registry-1.docker.io/bitnamicharts/cert-manager | ||
version: "1.3.1" |