https://pulumi.com logo
Title
b

bumpy-summer-9075

06/23/2021, 10:45 PM
Why is a
dependsOn
needed here?
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

little-cartoon-10569

06/23/2021, 10:47 PM
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

bored-oyster-3147

06/23/2021, 10:55 PM
I would expect that it isn’t needed and if it is I too would like to know why, lol
b

bumpy-summer-9075

06/23/2021, 11:11 PM
I've used
pulumi stack export
to make sure: Without dependsOn:
"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:
"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

little-cartoon-10569

06/23/2021, 11:15 PM
The dependency would be in the properties section, rather than the top level.
b

bumpy-summer-9075

06/24/2021, 12:04 AM
of which resource? The json above is the entire object with that URN
l

little-cartoon-10569

06/24/2021, 12:22 AM
Really? My resources are a lot bigger. Not at work computer right now, I'll dump a resource here in a few.
b

bumpy-summer-9075

06/24/2021, 12:27 AM
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

little-cartoon-10569

06/24/2021, 12:29 AM
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

bumpy-summer-9075

06/24/2021, 12:34 AM
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

little-cartoon-10569

06/24/2021, 12:38 AM
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:
{
  "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:
{
  "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

bumpy-summer-9075

06/24/2021, 12:45 AM
$ 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

little-cartoon-10569

06/24/2021, 12:47 AM
Well.. maybe just currently unexplained... 🙂
☝️ 1
😃 1
b

bored-oyster-3147

06/24/2021, 12:59 AM
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