Remove member variable 'pid' and function _update_pid() from PTL's daemon objects

Overview

When a test writer uses PTL's PBSInitServices's functions directly (instead of daemon's wrapper functions) (for example self.server.pi.restart()) in tests, followed by any operation that needs the latest pid like a self.server.signal(‘HUP”) PTL will fail because the newer pid is not updated in the daemon objects.

Some background : PTL’s Server, Mom, Scheduler and Comm objects store an internal cache of their daemon’s pid in the member variable ‘pid’. Every daemon object also contains an instance of PBSInitServices (member variable 'pi’ ) in order to do start, stop, restart operations. Wrapper functions start() stop() and restart() in every daemon class call PBSInitServices' functions like start(), restart(), start_server(), start_mom(), start_sched(), start_comm(), restart_server(), restart_mom(), restart_comm() and restart_sched() etc for respective operations. These wrapper functions then update their cache with latest pid(if it changes) via _update_pid() . PBSInitServices's functions do not update ‘pid’ in Server, sched and comm and mom objects when it changes.

Forum discussion

http://community.pbspro.org/t/remove-member-variable-pid-and-function-update-pid-from-ptls-daemon-objects/1544

Interface changes

This problem can be resolved if we always fetched the daemon process ids, using get_pid() rather than relying on the internal cache ‘pid’. get_pid() gets pid from daemon's lock file. There is no need for the member ‘pid’ in the daemon objects. Infact it is better to remove this variable to avoid access to incorrect (not latest) pid. With this change there is no need for the function _update_pid() and it can be removed.

The other way of fixing this would be making PBSInitServices’ functions capable of updating the 'pid' in daemon objects. This requires PBSInitServices to contain all daemon objects. This isn’t a correct approach as it would make PBSInitServices class bulky and also change its real purpose. 

In fw/ptl/lib/pbs_testlib.py,

  • Interface: class PBSService(PBSObject)

  • Synopsis: Removed the member 'pid'
    Details:  This member is removed as it doesn't always hold the correct/lates pid of objects


  • Interface: _update_pid(self, inst)
  • Synopsis: Removed this function
  • Details: This function is removed, as the member variable 'pid' it is operating on, is removed





OSS Site Map

Project Documentation Main Page

Developer Guide Pages