Commit 82b22e19 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Move job queue to new ganeti.runtime


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 0070a462
......@@ -59,6 +59,7 @@ from ganeti import objects
from ganeti import ssconf
from ganeti import serializer
from ganeti import netutils
from ganeti import runtime
_BOOT_ID_PATH = "/proc/sys/kernel/random/boot_id"
......@@ -2403,9 +2404,11 @@ def JobQueueUpdate(file_name, content):
"""
_EnsureJobQueueFile(file_name)
getents = runtime.GetEnts()
# Write and replace the file atomically
utils.WriteFile(file_name, data=_Decompress(content))
utils.WriteFile(file_name, data=_Decompress(content), uid=getents.masterd_uid,
gid=getents.masterd_gid)
def JobQueueRename(old, new):
......
......@@ -53,6 +53,7 @@ from ganeti import mcpu
from ganeti import utils
from ganeti import jstore
from ganeti import rpc
from ganeti import runtime
from ganeti import netutils
from ganeti import compat
......@@ -1070,7 +1071,9 @@ class JobQueue(object):
@param replicate: whether to spread the changes to the remote nodes
"""
utils.WriteFile(file_name, data=data)
getents = runtime.GetEnts()
utils.WriteFile(file_name, data=data, uid=getents.masterd_uid,
gid=getents.masterd_gid)
if replicate:
names, addrs = self._GetNodeIp()
......@@ -1314,8 +1317,11 @@ class JobQueue(object):
@param drain_flag: Whether to set or unset the drain flag
"""
getents = runtime.GetEnts()
if drain_flag:
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", close=True)
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="", close=True,
uid=getents.masterd_uid, gid=getents.masterd_gid)
else:
utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE)
......
......@@ -25,6 +25,7 @@ import errno
from ganeti import constants
from ganeti import errors
from ganeti import runtime
from ganeti import utils
......@@ -73,8 +74,7 @@ def InitAndVerifyQueue(must_lock):
locking mode.
"""
dirs = [(d, constants.JOB_QUEUE_DIRS_MODE) for d in constants.JOB_QUEUE_DIRS]
utils.EnsureDirs(dirs)
getents = runtime.GetEnts()
# Lock queue
queue_lock = utils.FileLock.Open(constants.JOB_QUEUE_LOCK_FILE)
......@@ -99,6 +99,7 @@ def InitAndVerifyQueue(must_lock):
if version is None:
# Write new version file
utils.WriteFile(constants.JOB_QUEUE_VERSION_FILE,
uid=getents.masterd_uid, gid=getents.masterd_gid,
data="%s\n" % constants.JOB_QUEUE_VERSION)
# Read again
......@@ -112,6 +113,7 @@ def InitAndVerifyQueue(must_lock):
if serial is None:
# Write new serial file
utils.WriteFile(constants.JOB_QUEUE_SERIAL_FILE,
uid=getents.masterd_uid, gid=getents.masterd_gid,
data="%s\n" % 0)
# Read again
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment