https://pulumi.com logo
Title
h

handsome-state-59775

05/06/2021, 6:25 AM
is it safe to operate on a different stack than the one currently selected?
stack_1 = auto.select_stack(...)
stack_2 = auto.create_or_select_stack(...)  # currently selected stack
stack_1.refresh_config()  # ok to do this now?
stack_1_config = stack1.get_all_config()  # ok to do this now?
2
l

little-cartoon-10569

05/06/2021, 7:48 AM
There is an issue from a few days back about working on two stacks in parallel (await / async stuff), but code like this where everything happens serially is fine.
You can flip back and forth between stacks as much as you like, in synchronous code.
👍 1
b

better-shampoo-48884

05/06/2021, 1:03 PM
on a side note - would it be ok to use a node.cluster() to execute multiple stacks in parallell (as they would be in separate child processes)? https://nodejs.org/api/cluster.html
l

little-cartoon-10569

05/06/2021, 8:27 PM
Further up this channel, maybe 3 or 4 days ago, there was a thread that mentioned a bit of shared internal memory ot config or something that caused problems when things were happening in parallel. I remember that @red-match-15116 was in the thread. And that's about all I know 🙂
r

red-match-15116

05/06/2021, 8:31 PM
So… the issue there was that
selectStack
and
createStack
change the currently selected stack which is a global setting (for a workspace). If these commands are executed in parallel in the same workspace they can have unexpected results and lead to odd bugs. I believe that if they are operating on separate workspaces this would not be a problem.
b

better-shampoo-48884

05/07/2021, 11:36 AM
right - and that's not related to memory, that's related to something disk-physical I presume (or some pulumi temp workdir) outside of the process? with a node.cluster() it creates seperate nodejs instances (with seperate pids and memory) - so was hoping that might be enough to isolate the runs.
r

red-match-15116

05/07/2021, 3:20 PM
Yes, I understand that. But even in those separate processes if you end up running these commands on the same workspace you will run into these issues. Because exactly as you said, it’s not about memory but the physical files on disk. Essentially I’m saying using node.cluster() should be fine just be aware of the gotchas. It will only bite in very specific situations.