https://pulumi.com logo
#dotnet
Title
# dotnet
h

high-france-81657

08/09/2022, 3:53 PM
Hi! Has anyone used OutputUtilities.CreateUnknown lately? It seems to hang my pulumi program.
e

echoing-dinner-19531

08/09/2022, 4:46 PM
You shouldn't generally be calling that, I think it's only exposed for some test scenarios
h

high-france-81657

08/09/2022, 6:47 PM
I'm seriously missing the dynamic providers feature from C#. I thought I'd be using this to not call external APIs for creating a value when it's only preview. What else could I do?
t

tall-librarian-49374

08/09/2022, 7:28 PM
I think you want
Deployment.Instance.IsDryRun
h

high-france-81657

08/09/2022, 7:28 PM
Yes.
What I'm trying to do is that if it is a dry run, then return an unknown, otherwise, call a REST endpoint and return its result
t

tall-librarian-49374

08/09/2022, 7:32 PM
Why do you want an unknown? Could you call your REST endpoint inside an if statement guarded with IsDryRun?
h

high-france-81657

08/09/2022, 7:32 PM
Because much of the config depends on the result of the REST call
I don't want to put the code full of if(value.IsValid) or something
t

tall-librarian-49374

08/09/2022, 7:36 PM
Output<MyStuff> x = null;
if (IsDryRun)
x = Output.Create(new MyStuff(someDefaults));
else
x = y.Apply(y => MyService.GetX(…));
new ResourceFoo("test", new ResourceFooArgs
{
Prop1 = x.Prop1
});
1
I was thinking about this - could you explain where this approach fails?
e

echoing-dinner-19531

08/09/2022, 8:29 PM
Ohhhh I see what your trying to do, and yeh that actually sounds very reasonable. Just to check your code is also checking
IsDryRun
and only returning the Unknown value when that's true?
🙌 1
h

high-france-81657

08/09/2022, 8:30 PM
@echoing-dinner-19531 yes, it is
@tall-librarian-49374 as the config is ~10 K SLOC, I really don't want to keep track whether x is a dummy value or not
t

tall-librarian-49374

08/09/2022, 8:43 PM
Why do you need to keep track of it beyond the initial assignment?
e

echoing-dinner-19531

08/09/2022, 9:07 PM
I think this should work as long as your being careful to only use it during dryruns. The snippet you posted at least runs fine for me.
h

high-france-81657

08/10/2022, 5:45 AM
@tall-librarian-49374 e.g. the REST API 1 creates an API 2 key, which could then end up in multiple config files that are pulumi resources or be used to call API 2 also from pulumi
@echoing-dinner-19531 you're right; if I extract this into a separate project, it doesn't hang. Let me investigate further.
Can't make an isolated example that hangs.
Any idea how to see what outputs are pending? (Given that I've attached a debugger to my pulumi program)
e

echoing-dinner-19531

08/10/2022, 8:26 AM
Not really, there's
Deployment.Instance.Internal.Runner._inFlightTasks._activeTasks
but that's just a counter. I'd try running with the engine debug logs on
--logtostderr -v10
and seeing what the last messages sent to the engine from the program are.
h

high-france-81657

08/10/2022, 2:30 PM
Just for the record: Cleaning up everything and redownloading, rebuilding my code has magically solved everything. Pardon me.
e

echoing-dinner-19531

08/10/2022, 10:28 PM
No worries 🙂 these oddities happen with software