Revision ff699aa9 lib/jstore.py
b/lib/jstore.py | ||
---|---|---|
22 | 22 |
"""Module implementing the job queue handling.""" |
23 | 23 |
|
24 | 24 |
import errno |
25 |
import os |
|
25 | 26 |
|
26 | 27 |
from ganeti import constants |
27 | 28 |
from ganeti import errors |
... | ... | |
134 | 135 |
raise |
135 | 136 |
|
136 | 137 |
return queue_lock |
138 |
|
|
139 |
|
|
140 |
def CheckDrainFlag(): |
|
141 |
"""Check if the queue is marked to be drained. |
|
142 |
|
|
143 |
This currently uses the queue drain file, which makes it a per-node flag. |
|
144 |
In the future this can be moved to the config file. |
|
145 |
|
|
146 |
@rtype: boolean |
|
147 |
@return: True if the job queue is marked drained |
|
148 |
|
|
149 |
""" |
|
150 |
return os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) |
|
151 |
|
|
152 |
|
|
153 |
def SetDrainFlag(drain_flag): |
|
154 |
"""Sets the drain flag for the queue. |
|
155 |
|
|
156 |
@type drain_flag: boolean |
|
157 |
@param drain_flag: Whether to set or unset the drain flag |
|
158 |
@attention: This function should only called the current holder of the queue |
|
159 |
lock |
|
160 |
|
|
161 |
""" |
|
162 |
getents = runtime.GetEnts() |
|
163 |
|
|
164 |
if drain_flag: |
|
165 |
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", |
|
166 |
uid=getents.masterd_uid, gid=getents.masterd_gid) |
|
167 |
else: |
|
168 |
utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE) |
|
169 |
|
|
170 |
assert (not drain_flag) ^ CheckDrainFlag() |
Also available in: Unified diff