[Scripting] SlaveUtils.SendRemoteCommand fails from event callback

7.1.2.1 on Fedora 19

When I try to use SlaveUtils.SendRemoteCommand from an OnSlaveStarted callback handler, I get this error:

=======================================================
Error
=======================================================
Event Error (OnSlaveStarted): can not create two instances of DeadlineApplicationManager

=======================================================
Type
=======================================================
InvalidOperationException

=======================================================
Stack Trace
=======================================================
  at Deadline.Applications.DeadlineApplicationManager..ctor () [0x00000] in <filename unknown>:0
  at Deadline.Monitor.MonitorManager..ctor () [0x00000] in <filename unknown>:0
  at Deadline.Monitor.MonitorManager.GetInstance () [0x00000] in <filename unknown>:0
  at Deadline.Scripting.SlaveUtils.SendRemoteCommand (System.String machineName, System.String command) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

Jon fixed one of these in Deadline 8.0 actually.

The problem there was that some core code was trying to pull some settings data (colour blending info) from the wrong data structure. One workaround is to remove any job errors from the queue (because, you know, that’s easy to do :stuck_out_tongue:).

It’s possible that it can happen a few places though (if we used the API incorrectly), so I should make sure it’s fixed in this one. Is the script portable enough for me to run?

I actually switched to using ClientUtils.ExecuteCommand instead, and that seems to work.

Yeah, a simplified calback handler method that should reproduce it would basically look like this:

def slaveStarted(self, slave):
    slaveInfo = RepositoryUtils.GetSlaveInfo(slave, True)
    SlaveUtils.SendRemoteCommand(slaveInfo.MachineRealName,
                                 'ForceStopSlave {0}'.format(slave))

Thanks Nathan! Jon got this fixed up now (it was a new case), and we’ll be refactoring some core components to avoid allowing this to happen again going forward.