azureautomation / runbooks

Sample Automation runbooks
MIT License
156 stars 129 forks source link

Powershell runbooks on hybrid workers can access other jobs variables if too many jobs are running at the same time #108

Open guinoronha2 opened 8 months ago

guinoronha2 commented 8 months ago

Hi! We have some user onboarding/offboarding scripts that run on hybrid workers. Sometimes, when there are several jobs running at the same time on the same hybrid worker, a script will eventually be able to read data from another job that is running at the same time.

A simplified example:

1 $Var1 = "1"
2 if ($Var1 -eq "1") {
3   $Email = "user@company.com"
4 }
5
6 .\ChildScript.ps1 -parameter1 "something" -parameter2 $Email

In Job 1, $Var1 is "1", so $Email will be created and populated with "user@company.com".

In Job 2, $Var1 is "6", so $Email is never created. It should be $null all along the script.

Expected behavior: In Job 2, line 6 will send nothing in parameter2. What happens: If there are many jobs running at the same time, sometimes Job 2 will send "user@company.com" on line 6, which is an e-mail that was assigned to $Email in Job 1.

It doesn't happen every time, but we were able to consistently trigger this by sending several jobs (50 to 80) at the same time.

Shouldn't the variables be sandboxed in it's own powershell process?

Additional info, in case it makes any difference: