gcron: create the lockfile if it is missing

The lockfile for the job may not exist yet. If that is the case, it
should be created upon the first time it is accessed.

Change-Id: I4da2b3ecdb79cc63ed82cc7bfa026c8f08d4d043
Fixes: bz#1590193
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2018-06-12 09:51:44 +02:00 committed by Amar Tumballi
parent 3808d8d46a
commit 7005b1a336

View File

@ -88,7 +88,7 @@ def takeSnap(volname="", snapname=""):
def doJob(name, lockFile, jobFunc, volname):
success = True
try:
f = os.open(lockFile, os.O_RDWR | os.O_NONBLOCK)
f = os.open(lockFile, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK)
try:
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
mtime = os.path.getmtime(lockFile)