pulumi-kubernetes icon indicating copy to clipboard operation
pulumi-kubernetes copied to clipboard

Explicit `DependsOn` on Helm Release ignored by getter generated resource

Open apjoseph opened this issue 3 years ago • 2 comments
trafficstars

What happened?

I have a Network Endpoint Group (NEG) that is created as a result of of a helm chart being deployed in a Kubernetes cluster. The NEG will not exist until the kubernetes provider deploys the helm chart that creates the NEG. So I use a getter and add an explicit dependsOn to reflect this situation:

  const negId = `https://www.googleapis.com/compute/v1/projects/${project}/zones/${zone}/networkEndpointGroups/${negName}`;

  const neg= gcp.compute.NetworkEndpointGroup.get(
    "neg",
    negId,
    undefined,
    {
      provider: gcpProvider,
      dependsOn: [helmChart],
    }
  );

But when I run pulumi up I receive :

error: Preview failed: resource 'https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/networkEndpointGroups/customneg' does not exist.

Steps to reproduce

Define the dependsOn property for a Resource generated by Resource.get for a resource that will not exist until it is created by another resource.

Expected Behavior

dependsOn respected and pulumi preview does not throw error.

Actual Behavior

dependsOn is ignored.

Versions used

Dependencies:
NAME                              VERSION
@pulumi/gcp                       6.30.0
@pulumi/kubernetes                3.19.4
@pulumi/pulumi                    3.35.3
joi                               17.6.0
lodash                            4.17.21
@babel/core                       7.18.6
@babel/preset-typescript          7.18.6
@swc/cli                          0.1.57
@swc/core                         1.2.207
@swc/helpers                      0.4.3
@types/lodash                     4.14.182
@types/node                       16.11.7
@typescript-eslint/eslint-plugin  5.30.1
@typescript-eslint/parser         5.30.1
eslint                            8.18.0
eslint-config-airbnb              19.0.4
eslint-config-airbnb-base         15.0.0
eslint-config-airbnb-typescript   17.0.0
eslint-config-prettier            8.5.0
eslint-plugin-import              2.26.0
eslint-plugin-jsx-a11y            6.6.0
eslint-plugin-prettier            4.2.1
eslint-plugin-react               7.30.1
eslint-plugin-react-hooks         4.6.0
jest                              28.1.2
prettier                          2.7.1
regenerator-runtime               0.13.9
ts-node                           10.8.1
typescript                        4.7.4

Additional context

I do get desired behavior if I generate the resource id by using an output from the helm resource:

  const negId = pulumi.all([helmRelease.status]).apply(async () => {
    return `https://www.googleapis.com/compute/v1/projects/${project}/zones/${zone}/networkEndpointGroups/${negName}`;
  });

But this is a crude hack.

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

apjoseph avatar Jul 02 '22 23:07 apjoseph

@apjoseph Try depending on helmChart.ready instead of the chart itself, per this example.

jkodroff avatar Jul 07 '22 14:07 jkodroff

@jkodroff I should have been more clear in that I was depending on a Helm Release and not a Helm Chart resource.

apjoseph avatar Jul 07 '22 14:07 apjoseph