Hi! Has anyone used OutputUtilities.CreateUnknown ...
# dotnet
h
Hi! Has anyone used OutputUtilities.CreateUnknown lately? It seems to hang my pulumi program.
e
You shouldn't generally be calling that, I think it's only exposed for some test scenarios
h
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
I think you want
Deployment.Instance.IsDryRun
h
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
Why do you want an unknown? Could you call your REST endpoint inside an if statement guarded with IsDryRun?
h
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
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
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
@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
Why do you need to keep track of it beyond the initial assignment?
e
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
@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
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
Just for the record: Cleaning up everything and redownloading, rebuilding my code has magically solved everything. Pardon me.
e
No worries 🙂 these oddities happen with software