Unable to set MachineLimits from OnSlaveStarted

I’m trying to set the whitelist of machine limits in the OnSlaveStart callback. These workers/slaves are cloud instances. I’m doing this because I’m spinning up instances for a particular job and I want to ensure the job only runs on those instances and that those instances don’t run any other jobs.

Initially, I was doing:

whiteListedWorkers = list(deadlineJob.JobListedSlaves) or []
print whiteListedWorkers 
RepositoryUtils.SetMachineLimit(jobId, 0, whiteListedWorkers, True, 0.0)

If I were to this with three instances, I found that two instances showed an empty list of whiteListedWorkers and one instance had one pre-existing node. This made me think it was a race condition. However, I could see at least one worker in the whitelist (in Deadline Monitor), so the methods were working.

Next, I tried RepositoryUtils.AddSlavesToMachineLimitList(jobId, [slave_name])… but now nothing shows up in the machine limit and I have no errors in worker log.

Any suggestions on the best way to go about this?

Would I have better luck with pools/groups?

In my experience, using pools and groups should make things easier for you.