pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
415 stars 115 forks source link

Creating a Helm release from a remote chart fails with `error: Chart.yaml file is missing` #2409

Open L3n41c opened 1 year ago

L3n41c commented 1 year ago

What happened?

We try to create a new Helm release from a remote chart with:

    return helm.NewRelease(e.Ctx, args.InstallName, &helm.ReleaseArgs{
        Namespace: pulumi.StringPtr("datadog"),
        Name:      pulumi.StringPtr("dda"),
        RepositoryOpts: helm.RepositoryOptsArgs{
            Repo: pulumi.StringPtr("https://helm.datadoghq.com"),
        },
        Chart:            pulumi.String("datadog"),
        CreateNamespace:  pulumi.BoolPtr(true),
        DependencyUpdate: pulumi.BoolPtr(true),
        ValueYamlFiles:   valueAssets,
        Values:           args.Values,
    }, opts...)

We use RepositoryOpts.Repo to indicate that the chart is to be fetched from a remote registry.

We get the following error:

Updating (lenaic-eks):
     Type                               Name                                    Status                  Info
[…]
 +   └─ kubernetes:helm.sh/v3:Release   dda                                     **creating failed**     1 error

Diagnostics:
  kubernetes:helm.sh/v3:Release (dda):
    error: Chart.yaml file is missing

If we increase the log level, we can see that the datadog chart is looked locally instead of on the remote registry:

    I0515 17:57:19.454989   36712 log.go:71] Setting registry client with config file: "/Users/vincent.boulineau/Library/Preferences/helm/registry.json" and debug: true
    I0515 17:57:19.455431   36712 log.go:71] Looking up chart path options for release: "dda"
    I0515 17:57:19.455443   36712 log.go:71] Chart name: "datadog"
    I0515 17:57:19.455497   36712 log.go:71] Trying to load chart from path: "/Users/vincent.boulineau/Documents/Dev/test-infra-definitions/datadog"
    I0515 17:57:19.456995   36712 log.go:71] getChart failed: Chart.yaml file is missing

This is caused by the fact that the current working directory contains a subdirectory which has exactly the same name as the chart we want to create. In this case, Helm tries to leverage the local directory instead of honoring the RepositoryOpts.Repo parameter.

Expected Behavior

Have helm fetch the remote chart from the registry.

Steps to reproduce

Try to create a Helm Release with helm.NewRelease with a RepositoryOpts.Repo parameter to specify the URL of the remote registry and create a folder inside the working directory with the same name as the chart.

Output of pulumi about

CLI          
Version      3.67.1
Go Version   go1.20.4
Go Compiler  gc

Plugins
NAME              VERSION
aws               5.30.0
awsx              1.0.2
azure-native      1.95.0
azure-native-sdk  1.95.0
azure-native-sdk  1.95.0
azure-native-sdk  1.95.0
command           0.7.1
docker            3.6.1
eks               1.0.1
go                unknown
kubernetes        3.24.1
libvirt           0.4.0
random            4.11.2

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in go: executable='/usr/bin/go' version='go version go1.18.1 linux/amd64'

Current Stack: organization/dd/lenaic-eks

TYPE                                               URN
pulumi:pulumi:Stack                                urn:pulumi:lenaic-eks::dd::pulumi:pulumi:Stack::dd-lenaic-eks
pulumi:providers:awsx                              urn:pulumi:lenaic-eks::dd::pulumi:providers:awsx::awsx
pulumi:providers:aws                               urn:pulumi:lenaic-eks::dd::pulumi:providers:aws::aws
aws:ec2/securityGroup:SecurityGroup                urn:pulumi:lenaic-eks::dd::aws:ec2/securityGroup:SecurityGroup::aws-eks-sg
aws:iam/role:Role                                  urn:pulumi:lenaic-eks::dd::aws:iam/role:Role::aws-eks-cluster-role
aws:iam/role:Role                                  urn:pulumi:lenaic-eks::dd::aws:iam/role:Role::aws-eks-linux-node-role
aws:iam/role:Role                                  urn:pulumi:lenaic-eks::dd::aws:iam/role:Role::aws-eks-windows-node-role
pulumi:providers:eks                               urn:pulumi:lenaic-eks::dd::pulumi:providers:eks::default
pulumi:providers:pulumi                            urn:pulumi:lenaic-eks::dd::pulumi:providers:pulumi::default
aws:iam/instanceProfile:InstanceProfile            urn:pulumi:lenaic-eks::dd::aws:iam/instanceProfile:InstanceProfile::aws-windows-ng
eks:index:Cluster                                  urn:pulumi:lenaic-eks::dd::eks:index:Cluster::aws-eks
pulumi:providers:aws                               urn:pulumi:lenaic-eks::dd::pulumi:providers:aws::default_5_16_2
eks:index:ServiceRole                              urn:pulumi:lenaic-eks::dd::eks:index:Cluster$eks:index:ServiceRole::aws-eks-podExecutionRole
aws:eks/cluster:Cluster                            urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:eks/cluster:Cluster::aws-eks-eksCluster
aws:iam/role:Role                                  urn:pulumi:lenaic-eks::dd::eks:index:Cluster$eks:index:ServiceRole$aws:iam/role:Role::aws-eks-podExecutionRole-role
aws:ec2/securityGroup:SecurityGroup                urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroup:SecurityGroup::aws-eks-nodeSecurityGroup
aws:iam/rolePolicyAttachment:RolePolicyAttachment  urn:pulumi:lenaic-eks::dd::eks:index:Cluster$eks:index:ServiceRole$aws:iam/rolePolicyAttachment:RolePolicyAttachment::aws-eks-podExecutionRole-6ad441d9
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroupRule:SecurityGroupRule::aws-eks-eksExtApiServerClusterIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroupRule:SecurityGroupRule::aws-eks-eksNodeIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroupRule:SecurityGroupRule::aws-eks-eksNodeInternetEgressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroupRule:SecurityGroupRule::aws-eks-eksNodeClusterIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:ec2/securityGroupRule:SecurityGroupRule::aws-eks-eksClusterIngressRule
pulumi:providers:kubernetes                        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$pulumi:providers:kubernetes::aws-eks-provider
pulumi:providers:kubernetes                        urn:pulumi:lenaic-eks::dd::eks:index:Cluster$pulumi:providers:kubernetes::aws-eks-eks-k8s
eks:index:VpcCni                                   urn:pulumi:lenaic-eks::dd::eks:index:Cluster$eks:index:VpcCni::aws-eks-vpc-cni
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::eks:index:Cluster$kubernetes:core/v1:ConfigMap::aws-eks-nodeAccess
aws:eks/fargateProfile:FargateProfile              urn:pulumi:lenaic-eks::dd::eks:index:Cluster$aws:eks/fargateProfile:FargateProfile::aws-eks-fargateProfile
eks:index:ManagedNodeGroup                         urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup::aws-linux-ng
aws:eks/nodeGroup:NodeGroup                        urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup$aws:eks/nodeGroup:NodeGroup::aws-linux-ng
eks:index:ManagedNodeGroup                         urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup::aws-linux-arm-ng
aws:eks/nodeGroup:NodeGroup                        urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup$aws:eks/nodeGroup:NodeGroup::aws-linux-arm-ng
eks:index:NodeGroup                                urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup::aws-windows-ng
eks:index:RandomSuffix                             urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$eks:index:RandomSuffix::aws-windows-ng-cfnStackName
aws:ec2/securityGroup:SecurityGroup                urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroup:SecurityGroup::aws-windows-ng-nodeSecurityGroup
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroupRule:SecurityGroupRule::aws-windows-ng-eksExtApiServerClusterIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroupRule:SecurityGroupRule::aws-windows-ng-eksNodeInternetEgressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroupRule:SecurityGroupRule::aws-windows-ng-eksClusterIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroupRule:SecurityGroupRule::aws-windows-ng-eksNodeClusterIngressRule
aws:ec2/securityGroupRule:SecurityGroupRule        urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/securityGroupRule:SecurityGroupRule::aws-windows-ng-eksNodeIngressRule
aws:ec2/launchConfiguration:LaunchConfiguration    urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:ec2/launchConfiguration:LaunchConfiguration::aws-windows-ng-nodeLaunchConfiguration
aws:cloudformation/stack:Stack                     urn:pulumi:lenaic-eks::dd::eks:index:NodeGroup$aws:cloudformation/stack:Stack::aws-windows-ng-nodes
eks:index:ManagedNodeGroup                         urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup::aws-bottlerocket-ng
aws:eks/nodeGroup:NodeGroup                        urn:pulumi:lenaic-eks::dd::eks:index:ManagedNodeGroup$aws:eks/nodeGroup:NodeGroup::aws-bottlerocket-ng
pulumi:providers:kubernetes                        urn:pulumi:lenaic-eks::dd::pulumi:providers:kubernetes::aws-k8s-provider
kubernetes:core/v1:Namespace                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Namespace::datadog
kubernetes:core/v1:Namespace                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Namespace::workload-dogstatsd
kubernetes:core/v1:ConfigMapPatch                  urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMapPatch::aws-eks-cni-cm
kubernetes:core/v1:Secret                          urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Secret::dda-datadog-credentials
kubernetes:core/v1:Namespace                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Namespace::workload-nginx
kubernetes:core/v1:Namespace                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Namespace::workload-prometheus
kubernetes:core/v1:Namespace                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Namespace::workload-redis
kubernetes:helm.sh/v3:Release                      urn:pulumi:lenaic-eks::dd::kubernetes:helm.sh/v3:Release::dda
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMap::dogstatsd
kubernetes:datadoghq.com/v1alpha1:DatadogMetric    urn:pulumi:lenaic-eks::dd::kubernetes:datadoghq.com/v1alpha1:DatadogMetric::nginx
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMap::nginx-query
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMap::nginx
kubernetes:policy/v1:PodDisruptionBudget           urn:pulumi:lenaic-eks::dd::kubernetes:policy/v1:PodDisruptionBudget::nginx
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMap::prometheus
kubernetes:datadoghq.com/v1alpha1:DatadogMetric    urn:pulumi:lenaic-eks::dd::kubernetes:datadoghq.com/v1alpha1:DatadogMetric::redis
kubernetes:core/v1:ConfigMap                       urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:ConfigMap::redis-query
kubernetes:policy/v1:PodDisruptionBudget           urn:pulumi:lenaic-eks::dd::kubernetes:policy/v1:PodDisruptionBudget::redis
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::redis
kubernetes:autoscaling/v2:HorizontalPodAutoscaler  urn:pulumi:lenaic-eks::dd::kubernetes:autoscaling/v2:HorizontalPodAutoscaler::nginx
kubernetes:core/v1:Service                         urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Service::redis
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::nginx
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::nginx-query
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::dogstatsd-udp
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::dogstatsd-uds
kubernetes:autoscaling/v2:HorizontalPodAutoscaler  urn:pulumi:lenaic-eks::dd::kubernetes:autoscaling/v2:HorizontalPodAutoscaler::redis
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::redis-query
kubernetes:core/v1:Service                         urn:pulumi:lenaic-eks::dd::kubernetes:core/v1:Service::nginx
kubernetes:apps/v1:Deployment                      urn:pulumi:lenaic-eks::dd::kubernetes:apps/v1:Deployment::prometheus

Found no pending operations associated with lenaic-eks

Backend        
Name           lenaic-Precision-5570
URL            gs://lenaic-pulumi
User           lenaic
Organizations  

Dependencies:
NAME                                                        VERSION
github.com/Masterminds/semver                               1.5.0
github.com/alessio/shellescape                              1.4.1
github.com/aws/aws-sdk-go-v2/config                         1.18.19
github.com/aws/aws-sdk-go-v2/service/ecs                    1.24.2
github.com/cenkalti/backoff/v4                              4.2.0
github.com/pulumi/pulumi-aws/sdk/v5                         5.30.0
github.com/pulumi/pulumi-awsx/sdk                           1.0.2
github.com/pulumi/pulumi-azure-native-sdk                   1.95.0
github.com/pulumi/pulumi-azure-native-sdk/compute           1.95.0
github.com/pulumi/pulumi-azure-native-sdk/containerservice  1.95.0
github.com/pulumi/pulumi-azure-native-sdk/network           1.95.0
github.com/pulumi/pulumi-command/sdk                        0.7.1
github.com/pulumi/pulumi-eks/sdk                            1.0.1
github.com/pulumi/pulumi-kubernetes/sdk/v3                  3.24.1
github.com/pulumi/pulumi-libvirt/sdk                        0.4.0
github.com/pulumi/pulumi-random/sdk/v4                      4.11.2
github.com/pulumi/pulumi/sdk/v3                             3.55.0
github.com/stretchr/testify                                 1.8.2

Pulumi locates its logs in /tmp by default

Additional context

If the current working directory subdirectory named with the same name as the chart is renamed to something different, the error goes away.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

kpitzen commented 1 year ago

Hi @L3n41c - I appreciate you not only opening this issue, but a corresponding PR as well! Engagement like this really makes my day. Looking forward to seeing the test results!

rquitales commented 1 year ago

Thanks for submitting #2410! I still think we may need one more PR to fully address this issue.

Consider a potential user journey where the local adjacent folder (eg datadog) also contains a Chart.yaml. The logic change in #2410 would still have Pulumi use the local folder rather than fetching it from the remote repository URL. If RepositoryOpts.Repo is specified explicitly, then I think it makes sense to always fetch the remote chart. We should also add some test cases to ensure this occurs.

EronWright commented 1 year ago

Folks, I am re-opening this issue to have a conversation about an unforeseen consequence, which is that Pulumi's behavior has diverged from that of Helm. The behavior of helm install is to prefer the local chart, without the fancy detection logic that was subsequently added. For example:

❯ mkdir metallb
❯ helm install metallb metallb -n metallb-system --dry-run --repo https://metallb.github.io/metallb
Error: INSTALLATION FAILED: Chart.yaml file is missing

Pulumi has a forked copy of the locateChart function, that was forked for an unrelated reason that has since been fixed (https://github.com/helm/helm/commit/9f199b6517c21394bca555983c70fc232d65014c). It would be nice to cleanup the forked code and to have consistent behavior between Helm and Pulumi. Thoughts?

EronWright commented 3 weeks ago

@rquitales are you supportive of re-aligning pulumi's behavior with that of the Helm CLI?

rquitales commented 3 weeks ago

@EronWright Yes, I think that's the right move as to not surprise any users expecting Helm behaviour.