pulumi / pulumi-java

Java support for Pulumi
Apache License 2.0
69 stars 21 forks source link

Serialization error when using helm to install a chart with Java #629

Open t0yv0 opened 2 years ago

t0yv0 commented 2 years ago

What happened?

Error when using helm to install a chart with Java.

Steps to reproduce

return new Release("nginx",
                ReleaseArgs.builder()
                        .chart("nginx-ingress")
                        .version("1.24.4")
                        .repositoryOpts(RepositoryOptsArgs.builder().repo("https://charts.helm.sh/stable").build())
                        .valueYamlFiles(new FileAsset("./values.yaml"))
                        .build(),
                CustomResourceOptions.builder()
                        .provider(provider)
                        .build());

Expected Behavior

Working code.

Actual Behavior

java.lang.UnsupportedOperationException: Convert [com.pulumi.kubernetes.helm.sh_v3.Release.resourceNames]: Error converting 'com.google.common.collect.RegularImmutableMap' to 'TypeShape{type=interface java.util.Map, parameters=[TypeShape{type=class java.lang.String, parameters=[]}, TypeShape{type=interface java.util.List, parameters=[]}]}'. Expected a parameter type for the List, got none

Versions used

No response

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

AaronFriel commented 2 years ago

@t0yv0 do you want to keep this on the triage queue until you get to it?

t0yv0 commented 2 years ago

Ah sorry about that, I just want to get it on @pawelprazak radar. I logged the issue from Community Slack. This does need fixing when possible so I can remove the label.

pawelprazak commented 2 years ago

This is the cause for the error, the annotation for exports does not support nested generic types, so List is raw/untyped. And the Converter validation is strict in this case currently.

@Export(name="resourceNames", type=Map.class, parameters={String.class, List.class})
private Output</* @Nullable */ Map<String,List<String>>> resourceNames;

The easiest solution would be to relax the converter validation, but I'm not sure about the second order consequences.

I don't expect that overcoming java annotations limits would be easy or readable, as discussed here https://stackoverflow.com/a/35776898/539481

t0yv0 commented 2 years ago

Since breaking changes to providers are becoming quite painful now, we should try to avoid that (e.g. make SDK work with "old codegen + new codegen") here. Thank you!

hnicke commented 2 years ago

I am still experiencing this problem.

Here is a complete stack definitition:

import com.pulumi.Context
import com.pulumi.Pulumi
import com.pulumi.kubernetes.helm.v3.Release
import com.pulumi.kubernetes.helm.v3.ReleaseArgs
import com.pulumi.kubernetes.helm.v3.inputs.RepositoryOptsArgs
import com.pulumi.resources.CustomResourceOptions

object App {
    @JvmStatic
    fun main(args: Array<String>) {
        Pulumi.run { pulumiContext: Context ->
            Release("nginx",
                ReleaseArgs.builder()
                    .chart("nginx-ingress")
                    .version("1.24.4")
                    .repositoryOpts(RepositoryOptsArgs.builder().repo("https://charts.helm.sh/stable").build())
                    .build(),
                CustomResourceOptions.builder()
                    .build());
        }
    }
}

pulumi up fails with the following exception: java.lang.UnsupportedOperationException: Convert [com.pulumi.kubernetes.helm.v3.Release.resourceNames]: Error converting 'com.google.common.collect.RegularImmutableMap' to 'TypeShape{type=interface java.util.Map, parameters=[TypeShape{type=class java.lang.String, parameters=[]}, TypeShape{type=interface java.util.List, parameters=[]}]}'. Expected a parameter type for the List, got none

Using pulumi 3.43.1 with pulumi-java 0.6.0. The changelog suggests this was fixed with 0.6.0 which seems to be false.

This issue should get reopened.

pawelprazak commented 2 years ago

@hnicke I'm speculating here, but there is a possibility that an old kubernetes provider is used and this may re-surface the problem.

It is possible to remove all kubernetes provider versions from local cache using this command:

pulumi plugin rm resource kubernetes

Afterwards, a new version would be downloaded automatically when doing pulumi up and will be visible in the output of pulumi plugin ls.

hnicke commented 2 years ago

Btw, in the build.gradle.kts, I'm using pulumi-kubernetes v3.21.4.

Output of pulumi plugin ls (before removing the plugin):

NAME           KIND      VERSION  SIZE    INSTALLED      LAST USED
azure          resource  4.11.0   235 MB  11 months ago  15 seconds ago
azure          resource  4.6.0    229 MB  1 year ago     15 seconds ago
azure          resource  4.1.0    225 MB  1 year ago     15 seconds ago
azure          resource  3.53.0   219 MB  2 years ago    15 seconds ago
azure          resource  3.50.0   216 MB  2 years ago    15 seconds ago
azure          resource  3.48.0   222 MB  2 years ago    15 seconds ago
azure          resource  3.4.0    177 MB  2 years ago    15 seconds ago
azure          resource  1.9.0    156 MB  2 years ago    15 seconds ago
azure-native   resource  1.19.0   42 MB   11 months ago  15 seconds ago
azure-native   resource  1.9.0    42 MB   1 year ago     15 seconds ago
azure-native   resource  1.4.0    41 MB   1 year ago     15 seconds ago
azure-native   resource  0.7.1    43 MB   2 years ago    15 seconds ago
azure-nextgen  resource  0.6.1    42 MB   2 years ago    15 seconds ago
azuread        resource  4.3.0    41 MB   11 months ago  15 seconds ago
azuread        resource  4.2.0    41 MB   1 year ago     15 seconds ago
azuread        resource  4.0.0    40 MB   1 year ago     15 seconds ago
azuread        resource  3.5.1    38 MB   2 years ago    15 seconds ago
azuread        resource  3.4.0    44 MB   2 years ago    15 seconds ago
azuread        resource  2.1.0    41 MB   2 years ago    15 seconds ago
azuread        resource  1.4.0    40 MB   2 years ago    15 seconds ago
gcp            resource  6.41.0   125 MB  3 days ago     15 seconds ago
gcp            resource  6.37.0   124 MB  1 month ago    15 seconds ago
gcp            resource  6.36.0   124 MB  1 month ago    15 seconds ago
gcp            resource  6.23.0   122 MB  4 months ago   15 seconds ago
kubernetes     resource  3.21.4   83 MB   3 days ago     15 seconds ago
kubernetes     resource  3.21.2   83 MB   1 month ago    15 seconds ago
kubernetes     resource  3.21.1   83 MB   1 month ago    15 seconds ago
kubernetes     resource  3.19.1   77 MB   4 months ago   15 seconds ago
kubernetes     resource  3.5.1    67 MB   11 months ago  15 seconds ago
kubernetes     resource  3.3.0    78 MB   1 year ago     15 seconds ago
kubernetes     resource  3.1.1    78 MB   1 year ago     15 seconds ago
kubernetes     resource  2.8.4    77 MB   2 years ago    15 seconds ago
kubernetes     resource  2.8.2    77 MB   2 years ago    15 seconds ago
kubernetes     resource  2.8.1    77 MB   2 years ago    15 seconds ago
kubernetes     resource  2.0.0    52 MB   2 years ago    15 seconds ago
kubernetes     resource  1.4.1    50 MB   2 years ago    15 seconds ago
random         resource  4.8.2    34 MB   1 month ago    15 seconds ago
random         resource  4.6.0    32 MB   4 months ago   15 seconds ago
random         resource  4.2.0    31 MB   1 year ago     15 seconds ago
random         resource  4.0.0    31 MB   1 year ago     15 seconds ago
random         resource  3.1.1    30 MB   2 years ago    15 seconds ago
random         resource  3.1.0    30 MB   2 years ago    15 seconds ago

TOTAL plugin cache size: 3.8 GB

I removed the cached kubernetes plugins:


This will remove 12 plugins from the cache:
    resource kubernetes-1.4.1
    resource kubernetes-2.0.0
    resource kubernetes-2.8.1
    resource kubernetes-2.8.2
    resource kubernetes-2.8.4
    resource kubernetes-3.1.1
    resource kubernetes-3.19.1
    resource kubernetes-3.21.1
    resource kubernetes-3.21.2
    resource kubernetes-3.21.4
    resource kubernetes-3.3.0
    resource kubernetes-3.5.1
Please confirm that this is what you'd like to do by typing `yes`: yes

I've removed all the other plugins from the cache as well.

During execution of the next pulumi up, it downloaded the kubernetes plugin again:

Downloading plugin kubernetes v3.21.4: 34.29 MiB / 34.29 MiB [======] 100.00% 3s

However, I'm still experiencing the same error (Expected a parameter type for the List, got none).

Output of pulumi about:

CLI          
Version      3.43.1
Go Version   go1.19.1
Go Compiler  gc

Plugins
NAME        VERSION
gcp         6.41.0
java        unknown
kubernetes  3.21.4
random      4.8.2

Host     
OS       arch
Version  
Arch     x86_64

This project is written in java: executable='/usr/bin/java' version='openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment (build 19.0.1+10)
OpenJDK 64-Bit Server VM (build 19.0.1+10, mixed mode)' java='/usr/bin/java' javac='19.0.1'
pawelprazak commented 2 years ago

Thank you for trying and for detailed response, it was worth a try ;)

It's unfortunate that the problem persists, we'll need to take a closer look.

ringgi commented 2 years ago

Unfortunately I run into the same problem trying to deploy a helm chart to GKE with java (using Kotlin). As in the pulumi helm package for java only the com.pulumi.kubernetes.helm.v3.Release class is available, I cannot test other strategies. Following my stacktrace, implementation and versions. Please tell me if I do something wrong here, as I need to deploy several different helm charts.

java.lang.UnsupportedOperationException: Convert [com.pulumi.kubernetes.helm.v3.Release.resourceNames]: Error converting 'com.google.common.collect.RegularImmutableMap' to 'TypeShape{type=interface java.util.Map, parameters=[TypeShape{type=class java.lang.String, parameters=[]}, TypeShape{type=interface java.util.List, parameters=[]}]}'. Expected a parameter type for the List, got none
        at com.pulumi.serialization.internal.Converter.convertObjectUntyped(Converter.java:119)
        at com.pulumi.serialization.internal.Converter.convertValue(Converter.java:86)
        at com.pulumi.core.internal.OutputCompletionSource.setValue(OutputCompletionSource.java:95)
        at
com.pulumi.deployment.internal.DeploymentImpl$ReadOrRegisterResourceInternal.lambda$completeResourceAsync$0(DeploymentImpl.java:1193)
        at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
        at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
    Caused by: java.lang.IllegalArgumentException: Expected a parameter type for the List, got none
        at com.pulumi.serialization.internal.Converter.lambda$tryConvertList$10(Converter.java:638)
        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
        at com.pulumi.serialization.internal.Converter.tryConvertList(Converter.java:638)
        at com.pulumi.serialization.internal.Converter.tryConvertObjectInner(Converter.java:277)
        at com.pulumi.serialization.internal.Converter.tryConvertMap(Converter.java:665)
        at com.pulumi.serialization.internal.Converter.tryConvertObjectInner(Converter.java:281)
        at com.pulumi.serialization.internal.Converter.convertObjectUntyped(Converter.java:115)
        ... 10 more

Failing implementation:

val certManager = Release(
      "cert-manager",
      ReleaseArgs.builder()
          .chart("cert-manager")
          .version("1.10.0")
          .repositoryOpts(
              RepositoryOptsArgs.builder()
                  .repo("https://charts.jetstack.io")
                  .build()
          )
          .build(),
      CustomResourceOptions.builder()
          .provider(provider)
          .build()
  )
  ctx.export("certManagerName", certManager.name())

Pulumi Java 0.6.0 Pulumi CLI 3.44.1
Pulumi Kubernetes Provider 3.22.1 Java version 17.0.4.1 OS Mac Monterey (intel)

jensbarthel commented 1 year ago

We are experiencing this problem using kotlin as well, when:

jensbarthel commented 1 year ago

Update: We found out that this seems to have been fixed in v0.6.0 and updated accordingly. Thanks guys :+1:

benediktarnold commented 1 year ago

I can confirm that this issue still exists with pulumi-java 0.6.0. Even tried the latest kubernetes alpha plugin and it didn't make a difference.

hnicke commented 1 year ago

Can confirm that unfortunately the issue still persists with all pulumi dependencies being up-to-date.

hnicke commented 1 year ago

As of now, all helm chart installations are working fine for me! :partying_face: I'm using the latest version of all plugins and pulumi itself.