Revision 686d7433

b/lib/cli.py
655 655
    obuf.write("Failure: command execution error:\n%s" % msg)
656 656
  elif isinstance(err, errors.TagError):
657 657
    obuf.write("Failure: invalid tag(s) given:\n%s" % msg)
658
  elif isinstance(err, errors.JobQueueDrainError):
659
    obuf.write("Failure: the job queue is marked for drain and doesn't"
660
               " accept new requests\n")
658 661
  elif isinstance(err, errors.GenericError):
659 662
    obuf.write("Unhandled Ganeti error: %s" % msg)
660 663
  elif isinstance(err, luxi.NoMasterError):
b/lib/constants.py
333 333
JOB_QUEUE_VERSION_FILE = QUEUE_DIR + "/version"
334 334
JOB_QUEUE_SERIAL_FILE = QUEUE_DIR + "/serial"
335 335
JOB_QUEUE_ARCHIVE_DIR = QUEUE_DIR + "/archive"
336
JOB_QUEUE_DRAIN_FILE = QUEUE_DIR + "/drain"
336 337

  
337 338
JOB_ID_TEMPLATE = r"\d+"
338 339

  
b/lib/errors.py
243 243
  """
244 244

  
245 245

  
246
class JobQueueDrainError(JobQueueError):
247
  """Job queue is marked for drain error.
248

  
249
  This is raised when a job submission attempt is made but the queue
250
  is marked for drain.
251

  
252
  """
253

  
254

  
246 255
# errors should be added above
247 256

  
248 257

  
b/lib/jqueue.py
564 564

  
565 565
    return [self._LoadJobUnlocked(job_id) for job_id in job_ids]
566 566

  
567
  @staticmethod
568
  def _IsQueueMarkedDrain():
569
    """Check if the queue is marked from drain.
570

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

  
574
    """
575
    return os.path.exists(constants.JOB_QUEUE_DRAIN_FILE)
576

  
567 577
  @utils.LockedMethod
568 578
  @_RequireOpenQueue
569 579
  def SubmitJob(self, ops):
......
576 586
    @param ops: The list of OpCodes that will become the new job.
577 587

  
578 588
    """
589
    if self._IsQueueMarkedDrain():
590
      raise errors.JobQueueDrainError()
579 591
    # Get job identifier
580 592
    job_id = self._NewSerialUnlocked()
581 593
    job = _QueuedJob(self, job_id, ops)

Also available in: Unified diff