Revision ff699aa9 lib/jqueue.py

b/lib/jqueue.py
29 29

  
30 30
"""
31 31

  
32
import os
33 32
import logging
34 33
import errno
35 34
import re
......
1230 1229

  
1231 1230
    self._queue_size = 0
1232 1231
    self._UpdateQueueSizeUnlocked()
1233
    self._drained = self._IsQueueMarkedDrain()
1232
    self._drained = jstore.CheckDrainFlag()
1234 1233

  
1235 1234
    # Setup worker pool
1236 1235
    self._wpool = _JobQueueWorkerPool(self)
......
1629 1628
      logging.exception("Can't load/parse job %s", job_id)
1630 1629
      return None
1631 1630

  
1632
  @staticmethod
1633
  def _IsQueueMarkedDrain():
1634
    """Check if the queue is marked from drain.
1635

  
1636
    This currently uses the queue drain file, which makes it a
1637
    per-node flag. In the future this can be moved to the config file.
1638

  
1639
    @rtype: boolean
1640
    @return: True of the job queue is marked for draining
1641

  
1642
    """
1643
    return os.path.exists(constants.JOB_QUEUE_DRAIN_FILE)
1644

  
1645 1631
  def _UpdateQueueSizeUnlocked(self):
1646 1632
    """Update the queue size.
1647 1633

  
......
1657 1643
    @param drain_flag: Whether to set or unset the drain flag
1658 1644

  
1659 1645
    """
1660
    getents = runtime.GetEnts()
1661

  
1662
    if drain_flag:
1663
      utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", close=True,
1664
                      uid=getents.masterd_uid, gid=getents.masterd_gid)
1665
    else:
1666
      utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE)
1646
    jstore.SetDrainFlag(drain_flag)
1667 1647

  
1668 1648
    self._drained = drain_flag
1669 1649

  

Also available in: Unified diff