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

Fix error for helm.Release previews with computed values #1760

Merged
merged 4 commits into from
Oct 8, 2021

Conversation

lblackstone
Copy link
Member

Proposed changes

The helm.Release resource was not checking for computed
values in the configuration during preview, which led to
various failures in code that expects only resolved values.

Related issues (optional)

Fix #1725

The helm.Release resource was not checking for computed
values in the configuration during preview, which led to
various failures in code that expects only resolved values.
@lblackstone lblackstone force-pushed the lblackstone/helm-release-preview branch from 8de76db to aacab02 Compare October 7, 2021 16:01
@github-actions
Copy link

github-actions bot commented Oct 7, 2021

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

2 similar comments
@github-actions
Copy link

github-actions bot commented Oct 7, 2021

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@@ -1218,6 +1212,13 @@ func (k *kubeProvider) Check(ctx context.Context, req *pulumirpc.CheckRequest) (
}
newInputs = annotatedInputs

if isHelmRelease(urn) && !hasComputedValue(newInputs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How disruptive is that? Say, we have 9 plain values and 1 computed value - wouldn't we still want to run Check for those 9 plain values? Should we teach helmReleaseProvider to work with computed values instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helm release check attempts to unmarshal the arguments, which doesn't work with computed values. The rest of the check after unmarshaling involves talking to the helm client, so it's not possible without resolved values. I can't think of a case where we could do useful checking (specific to Release) with unresolved values, so I think it's fine to only do the checks at the k8s provider layer.

To clarify, all of the normal Check logic still runs at the k8s provider layer, so the preview would look something like this:

+ pulumi:pulumi:Stack: (create)
    [urn=urn:pulumi:dev::pulumi-k8s-test::pulumi:pulumi:Stack::pulumi-k8s-test-dev]
    + random:index/randomPet:RandomPet: (create)
        [urn=urn:pulumi:dev::pulumi-k8s-test::random:index/randomPet:RandomPet::test]
        [provider=urn:pulumi:dev::pulumi-k8s-test::pulumi:providers:random::default_4_2_0::04da6b54-80e4-46f7-96ec-b56ff0331ba9]
        length    : 2
        separator : "-"
    + kubernetes:core/v1:Namespace: (create)
        [urn=urn:pulumi:dev::pulumi-k8s-test::kubernetes:core/v1:Namespace::test]
        [provider=urn:pulumi:dev::pulumi-k8s-test::pulumi:providers:kubernetes::default_3_9_0_alpha_1633622661_9bc68e49_dirty::04da6b54-80e4-46f7-96ec-b56ff0331ba9]
        apiVersion: "v1"
        kind      : "Namespace"
        metadata  : {
            labels: {
                app.kubernetes.io/managed-by: "pulumi"
            }
            name  : output<string>
        }
    + kubernetes:helm.sh/v3:Release: (create)
        [urn=urn:pulumi:dev::pulumi-k8s-test::kubernetes:helm.sh/v3:Release::nginx]
        [provider=urn:pulumi:dev::pulumi-k8s-test::pulumi:providers:kubernetes::default_3_9_0_alpha_1633622661_9bc68e49_dirty::04da6b54-80e4-46f7-96ec-b56ff0331ba9]
        chart         : "nginx"
        compat        : "true"
        metadata      : {
            annotations: {
                pulumi.com/autonamed: "true"
            }
            labels     : {
                app.kubernetes.io/managed-by: "pulumi"
            }
            name       : "nginx-wj35smcw"
        }
        namespace     : output<string>
        repositoryOpts: {
            repo: "https://charts.bitnami.com/bitnami"
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thank you. Should we remove KeepUnknowns: true from here then? https://github.com/pulumi/pulumi-kubernetes/blob/master/provider/pkg/provider/helm_release.go#L261

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think we can remove all references to keepUnkowns in helm_release.

@@ -1431,6 +1426,13 @@ func (k *kubeProvider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*p
return nil, err
}

if isHelmRelease(urn) && !hasComputedValue(newInputs) {
if !k.clusterUnreachable {
return k.helmReleaseProvider.Diff(ctx, req)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question for Diff I guess. How does the helm-release diff differ from the default diff and are we ready to lose that for any computed value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viveklak can verify, but I don't think it will be possible to get a more detailed Release diff with computed values since it requires talking to Helm. We still get all the normal provider diffing, which shows client-side config changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah unfortunately we need to rely on helm's ability to handle the templated values which won't be possible with computed values. I believe this is the same experience with helm charts as well.

provider/pkg/provider/provider.go Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Oct 8, 2021

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@lblackstone lblackstone merged commit ff43b7c into master Oct 8, 2021
@pulumi-bot pulumi-bot deleted the lblackstone/helm-release-preview branch October 8, 2021 16:48
@EronWright
Copy link
Contributor

A relevant follow-up: #1953

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 this pull request may close these issues.

[Helm/Release] Does not accept an Output in the chart values
4 participants