Logs symlinks creation fixed

We had a race on the old symlink recreation. After old symlink
removing rsyslog creates a dir with old name and after that
symlink creation is failed due to 'File exists' error. As fix
we are stopping the rsyslog for removing old link as well as
it was done for removing old dir.

Change-Id: I7fa969c3495f7e15a3b9f44ee9eaccca4106d5c1
Closes-Bug: #1652771
This commit is contained in:
Alexander Kislitsky 2017-01-11 17:53:10 +03:00
parent ca498021fd
commit 46c859acc0
1 changed files with 1 additions and 2 deletions

View File

@ -62,13 +62,12 @@ def prepare_syslog_dir(node, prefix=settings.SYSLOG_DIR):
try:
# rename bootstrap directory into fqdn
subprocess.check_call(["/usr/bin/pkill", "-STOP", "rsyslog"])
if os.path.islink(old):
logger.debug("Old %s exists and it is link. "
"Trying to unlink", old)
os.unlink(old)
if os.path.isdir(old):
subprocess.check_call(["/usr/bin/pkill", "-STOP", "rsyslog"])
logger.debug("Old %s exists and it is directory. "
"Trying to rename into %s", old, new)
os.rename(old, new)