Why is a `dependsOn` needed here? ```export class ...
# general
b
Why is a
dependsOn
needed here?
Copy code
export class CertManager extends pulumi.ComponentResource {
  constructor(name: string, {}: CertManagerArgs, opts?: pulumi.ComponentResourceOptions) {
    super('foo::bar::CertManager', name, {}, opts);

    const certManagerNamespace = new k8s.core.v1.Namespace(
      'cert-manager',
      {metadata: {name: 'cert-manager'}},
      {parent: this},
    );

    const helmChart = new k8s.helm.v3.Chart(
      'cert-manager',
      {
        namespace: certManagerNamespace.metadata.name, // I thought this would create a dependency between the two resources
        // ...
      },
      {parent: this, dependsOn: [certManagerNamespace]}, // Why is this needed?
    );
  }
}
l
Is it definitely needed? If it isn't redundant, then I would guess that the namespace adds a definition on certManagerNamespace.metadata, which might not be precise enough?
b
I would expect that it isn’t needed and if it is I too would like to know why, lol
b
I've used
pulumi stack export
to make sure: Without dependsOn:
Copy code
"urn": "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager$kubernetes:<http://helm.sh/v3:Chart::cert-manager|helm.sh/v3:Chart::cert-manager>",
"custom": false,
"type": "kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart>",
"parent": "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager::remoteinfra-cert-manager",
"aliases": [
    "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager$kubernetes:<http://helm.sh/v2:Chart::cert-manager|helm.sh/v2:Chart::cert-manager>"
]
with:
Copy code
"urn": "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager$kubernetes:<http://helm.sh/v3:Chart::cert-manager|helm.sh/v3:Chart::cert-manager>",
"custom": false,
"type": "kubernetes:<http://helm.sh/v3:Chart|helm.sh/v3:Chart>",
"parent": "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager::remoteinfra-cert-manager",
"dependencies": [
    "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager$kubernetes:core/v1:Namespace::cert-manager"
],
"aliases": [
    "urn:pulumi:dev::infra-do-cluster::foo:bar:CertManager$kubernetes:<http://helm.sh/v2:Chart::cert-manager|helm.sh/v2:Chart::cert-manager>"
]
The chart doesn't fail because creating a NS is almost instantaneous, but I expected the dependency to be there
l
The dependency would be in the properties section, rather than the top level.
b
of which resource? The json above is the entire object with that URN
l
Really? My resources are a lot bigger. Not at work computer right now, I'll dump a resource here in a few.
b
No worries! Most of my resources are big, but the top-level resource for helm charts is tiny, since I guess it's only just a "container"
l
The stack export property I'm thinking of is
propertyDependencies
, which in my stack includes every property for a given resource. Most properties have dependency
null
.
But looking through my stack, I see that not every resource has this property. EC2 instances don't have it... weird...
Neither do providers or stack references, but that's fair.
b
I'll dig a little bit more on this, I really don't see any links/dependencies between the chart and the namespace unless I explicitely declare a
dependsOn
From what I understand, it should; I wasn't sure about this so before investigating further I thought I'd ask
l
Ah.. I found out why the EC2 instance has no dependency on the keypair that it is really dependent on, so let's see if the same thing applies in your stack.
There's two things that look like my EC2 instance: this is what I thought was the instance first time:
Copy code
{
  "urn": "urn:pulumi:preprod::pams::pams:aws:pams$iqa:aws:ec2:instance::preprod-web",
  "custom": false,
  "type": "iqa:aws:ec2:instance",
  "parent": "urn:pulumi:preprod::pams::pams:aws:pams::preprod"
}
But that's just some sort of reference, in a deployment-level item called "resources".
👀 1
There's a real EC2 instance resource with a very different URN:
Copy code
{
  "urn": "urn:pulumi:preprod::pams::pams:aws:pams$iqa:aws:ec2:instance$aws:ec2/instance:Instance::preprod-web",
  "type": "aws:ec2/instance:Instance",
  ...
That's the one that has the
propertyDependencies
So maybe there's something else in your stack that also represents the same resource,
On closer inspection, that first one is my ComponentResource.
b
Copy code
$ cat state.json | grep -i 'namespace::cert-manager'

"urn": "urn:pulumi:dev::infra-do-cluster::foo:kubernetes:CertManager$kubernetes:core/v1:Namespace::cert-manager",
nothing points to it anywhere
I'll try to do a minimal reproductible project and see if it happens on a fresh stack, and if so submit a bug report
👍 1
Thanks for your help; it helped me confirm that what I was seeing was abnormal
l
Well.. maybe just currently unexplained... 🙂
☝️ 1
😃 1
b
I would open the provider source for the helm chart and see if the output on that property is being instantiated in such a way that it doesn’t have dependency information