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

Failure previewing Helm Chart with unconfigured provider #2162

Closed
eraofalexander opened this issue Sep 8, 2022 · 3 comments · Fixed by #2172
Closed

Failure previewing Helm Chart with unconfigured provider #2162

eraofalexander opened this issue Sep 8, 2022 · 3 comments · Fixed by #2172
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec p1 A bug severe enough to be the next item assigned to an engineer resolution/fixed This issue was fixed
Milestone

Comments

@eraofalexander
Copy link

What happened?

Hi, I'm trying to get the pulumi to execute a helm chart into my newly created aks cluster. When I specify the provider using your example (https://github.com/pulumi/examples/tree/master/azure-cs-aks-helm) I get the error listed in Actual Behavior.

Steps to reproduce

 Kubeconfig = ListManagedClusterUserCredentials.Invoke(
                new ListManagedClusterUserCredentialsInvokeArgs
                {
                    ResourceGroupName = _cfg.ResourceGroupName,
                    ResourceName = k8sCluster.Name
                })
                .Apply(x => x.Kubeconfigs[0].Value)
                .Apply(Convert.FromBase64String)
                .Apply(Encoding.UTF8.GetString);

            Provider = new K8s.Provider("k8s-provider", new K8s.ProviderArgs
            {
                KubeConfig = Kubeconfig
            });
public Output<string> Execute(string nginxVersion, Resource cluster, K8s.Provider provider)
        {
            var nginx = new Chart("nginx-ingress", new ChartArgs
            {
                Chart = "nginx-ingress",
                Version = nginxVersion,
                Namespace = "nginx",
                FetchOptions = new ChartFetchArgs
                {
                    Repo = "https://charts.helm.sh/stable"
                }
            }, new ComponentResourceOptions
            {
                DependsOn = new InputList<Resource> { cluster },
                Provider = provider
            });

            return nginx.GetResource<Service>("nginx-ingress-controller", "nginx")
                  .Apply(svc => svc.Status.Apply(s => s.LoadBalancer.Ingress[0].Ip));
        }

Expected Behavior

To not list any errors.

Actual Behavior

pulumi:pulumi:Stack (pulum-dev):
    error: Running program 'C:\Repo\infrastructure\pulumi\bin\Debug\net6.0\pulum.dll' failed with an unhandled exception:
    System.NullReferenceException: Object reference not set to an instance of an object.
       at ImmutableArray<TResult> System.Collections.Immutable.ImmutableArray.CreateRange<TSource, TResult>(ImmutableArray<TSource> items, Func<TSource, TResult> selector)
       at ImmutableArray<TResult> Pulumi.Extensions.SelectAsArray<TItem, TResult>(ImmutableArray<TItem> items, Func<TItem, TResult> map)
       at InputList<T> Pulumi.InputList<T>.op_Implicit(ImmutableArray<T> values)
       at Output<ImmutableDictionary<string, KubernetesResource>> Pulumi.Kubernetes.Helm.V3.Chart.ParseTemplate(Union<ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet<Resource> dependsOn, ComponentResourceOptions options)+(ImmutableArray<ImmutableDictionary<string, object>> objs) => { }
       at async Task<OutputData<U>> Pulumi.Output<T>.ApplyHelperAsync<U>(Task<OutputData<T>> dataTask, Func<T, Output<U>> func) x 2
       at async Task<OutputData<object>> Pulumi.Output<T>.Pulumi.IOutput.GetDataAsync()
       at async Task<object> Pulumi.Serialization.Serializer.SerializeAsync(string ctx, object prop, bool keepResources, bool keepOutputValues)
       at async Task<RawSerializationResult> Pulumi.Deployment.SerializeFilteredPropertiesRawAsync(string label, IDictionary<string, object> args, Predicate<string> acceptKey, bool keepResources, bool keepOutputValues)
       at async Task<SerializationResult> Pulumi.Deployment.SerializeFilteredPropertiesAsync(string label, IDictionary<string, object> args, Predicate<string> acceptKey, bool keepResources, bool keepOutputValues)
       at async Task<Struct> Pulumi.Deployment.SerializeAllPropertiesAsync(string label, IDictionary<string, object> args, bool keepResources, bool keepOutputValues)
       at async Task Pulumi.Deployment.RegisterResourceOutputsAsync(Resource resource, Output<IDictionary<string, object>> outputs)

Output of pulumi about

running 'dotnet build -nologo .'
Determining projects to restore...

All projects are up-to-date for restore.
pulum -> C:\Repo\infrastructure\pulumi\bin\Debug\net6.0\pulum.dll

Build succeeded.

[C:\Repo\infrastructure\pulumi\pulum.csproj]
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:02.61

'dotnet build -nologo .' completed successfully
CLI
Version 3.39.2
Go Version go1.19
Go Compiler gc

Plugins
NAME VERSION
azure-native 1.74.0
azuread 5.28.0
dotnet unknown
kubernetes 3.21.2
random 4.8.2
tls 4.6.1

Host
OS Microsoft Windows 10 Pro
Version 10.0.19044 Build 19044
Arch x86_64

This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='6.0.400'

Dependencies:
NAME VERSION
Pulumi 3.39.2
Pulumi.AzureAD 5.28.0
Pulumi.AzureNative 1.74.0
Pulumi.Kubernetes 3.21.2
Pulumi.Random 4.8.2
Pulumi.Tls 4.6.1

Additional context

No response

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).

@eraofalexander eraofalexander added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 8, 2022
@eraofalexander
Copy link
Author

After spending some more time on this. I found out if I do Providers = new List<ProviderResource> { provider } instead of Provider = provider it will work..

@mikhailshilkov mikhailshilkov transferred this issue from pulumi/pulumi Sep 8, 2022
@viveklak
Copy link
Contributor

viveklak commented Sep 9, 2022

This might be the dotnet incarnation of #2038. Verifying.

@viveklak viveklak removed the needs-triage Needs attention from the triage team label Sep 9, 2022
@viveklak viveklak self-assigned this Sep 9, 2022
@viveklak viveklak added this to the 0.78 milestone Sep 9, 2022
@viveklak viveklak added the p1 A bug severe enough to be the next item assigned to an engineer label Sep 9, 2022
@viveklak viveklak changed the title net6.0 K8s.Provider Failure previewing Helm Chart with unconfigured provider Sep 12, 2022
@viveklak
Copy link
Contributor

viveklak commented Sep 12, 2022

This is indeed the C# variation of #2038 and was missed during the initial fix.

The change in #2172 will avoid the error - however, there are some limitations:

  1. When the kubernetes provider refers to a kubeconfig that doesn't exist, the resources will not be rendered during preview
  2. A Get on the chart resources in the above circumstances will not be queryable during preview. i.e. the get on the service here: https://github.com/pulumi/examples/blob/master/azure-cs-aks-helm/MyStack.cs#L37 will fail if the kubernetes provider is not fully initialized for a running cluster. I will update the example once this goes in with workarounds.

viveklak added a commit that referenced this issue Sep 12, 2022
…2172)

* Fix invoke on helm template returning empty response (#2162)

* Changelog
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec p1 A bug severe enough to be the next item assigned to an engineer resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants