https://pulumi.com logo
f

faint-motherboard-95438

05/18/2020, 10:13 PM
Hi there, I’m trying to understand how
dependsOn
works and if it’s the solution to my problem. From what I understand here https://www.pulumi.com/docs/intro/concepts/programming-model/#dependson it should properly wait for a previous resource to be available for the one I’m referencing it in. In my usecase I provision postgresql with an helm chart and my migration service needs to wait in order to connect to it. Unfortunately, having inputs from the chart nor having it explicitly define in the
dependsOn
does not make my service wait for all the services in the chart available and of course it fails since the database service is not available yet. How am I supposed to properly define dependencies when pulumi fails to understand a specific case then ?
b

busy-umbrella-36067

05/18/2020, 10:15 PM
did you add
dependsOn
to the chart or inside the
transformations
f

faint-motherboard-95438

05/18/2020, 10:16 PM
@busy-umbrella-36067 sorry no, I use
dependsOn
in a following
ComponentResource
of mine which depends on the database helm chart to be fully up&running
b

busy-umbrella-36067

05/18/2020, 10:18 PM
ah, so your component starts creating even though you have it set to depend on the chart
f

faint-motherboard-95438

05/18/2020, 10:18 PM
correct
it starts randomly, and does not care at all about the chart status
b

busy-umbrella-36067

05/18/2020, 10:19 PM
I would look around accessing individual resources of a helm chart
I believe they had some sort of way to do that, instead of referencing the whole chart.
f

faint-motherboard-95438

05/18/2020, 10:19 PM
The chart is in another
ComponentResource
to be precise. I tried to depends on this “container” and also directly on the chart inside itself, both failed.
b

busy-umbrella-36067

05/18/2020, 10:20 PM
The other thing I can think of is a
Job
which loops until your DB is reachable.
you could depend on the job and it should be guaranteed to work
f

faint-motherboard-95438

05/18/2020, 10:21 PM
I think I can do that, but that’s tedious, I had hope pulumi should be “smart” to understand the
ComponentResource
and
Chart
dependencies. I’ll try that
Never tried a
Job
, will have a look, but that’s kind of “dirty” workaround I guess
Thanks for the inputs @busy-umbrella-36067 i’ll try those few shots
b

busy-umbrella-36067

05/18/2020, 10:22 PM
Agreed, its not ideal (I would call it jank) Thats why I would research on how to access one of the 10+ resources the chart creates instead of the whole chart before I go with the
Job
f

faint-motherboard-95438

05/18/2020, 10:28 PM
@busy-umbrella-36067 there’s a
chart.getResource()
method, trying right now
👍 1
g

gorgeous-egg-16927

05/18/2020, 10:29 PM
b

busy-umbrella-36067

05/18/2020, 10:30 PM
Nice, this might also be helpful if you wanna just depend on your component resource https://www.pulumi.com/docs/intro/concepts/programming-model/#registering-component-outputs You could register the resource you get from
chart.getResource()
as an output and that way all you would need to
dependsOn
is your first component
The call to registerOutputs also tells Pulumi that the resource is done registering children and should be considered fully constructed, so—although it's not enforced—the best practice is to call it in all components even if no outputs need to be registered.
f

faint-motherboard-95438

05/18/2020, 10:34 PM
@busy-umbrella-36067 right ! I forgot about that. I can confirm using
getResource()
works and my component holds until the database services are up. Will try the cleaner way with
registerOutputs()
right away
@busy-umbrella-36067 @gorgeous-egg-16927 while using
getResource()
and directly depending on the resource(s) needed in
dependsOn
works, registering the same resource(s) in
registerOutputs()
and only using the top
ComponentResource
as a dependency unfortunately does not work as expected. I’ll stick to direct references the resources I need to wait for, for now. Thanks for your help !
👍 1
b

busy-umbrella-36067

05/18/2020, 10:42 PM
what if you use the output as an input
and ditch
dependsOn
altogether
I’m assuming its something like a hostname, so that might not actually work. Never mind
f

faint-motherboard-95438

05/18/2020, 10:44 PM
not sure that would help and I actually does not really have a direct input from the chart, so that would make things more messy. But that could maybe trigger a dependency in some other cases.
I’ll track the issue and i’ll refactor once it will be solved, for now I can live with this (small) workaround.
thanks again !