build: remove link to failed log before creating

Kolla allows to create separate logs per image. It also makes very
useful symlinks to those builds which fail.

But it fails to do that on next builds:

ERROR:kolla.common.utils:aodh-base Failed with status: error
Traceback (most recent call last):
  File "./tools/build.py", line 40, in <module>
    sys.exit(main())
  File "./tools/build.py", line 30, in main
    statuses = build.run_build()
  File "/home/hrw/devel/kolla/kolla/image/build.py", line 1333, in run_build
    results = kolla.summary()
  File "/home/hrw/devel/kolla/kolla/image/build.py", line 1037, in summary
    "000_FAILED_%s.log" % name))
FileExistsError: [Errno 17] File exists: 'aodh-base.log' -> 'logs/debian-source-buster/000_FAILED_aodh-base.log'

Change-Id: I85132bbace63c8b386f69ddb758a3b52e52c0ef0
This commit is contained in:
Marcin Juszkiewicz 2018-10-23 17:00:19 +02:00 committed by Marcin Juszkiewicz
parent f613ff8a54
commit 5792c1d7b4
1 changed files with 9 additions and 3 deletions

View File

@ -1032,9 +1032,15 @@ class KollaWorker(object):
'status': status,
})
if self.conf.logs_dir and status == STATUS_ERROR:
os.symlink("%s.log" % name,
os.path.join(self.conf.logs_dir,
"000_FAILED_%s.log" % name))
linkname = os.path.join(self.conf.logs_dir,
"000_FAILED_%s.log" % name)
try:
os.lstat(linkname)
os.remove(linkname)
except OSError:
pass
os.symlink("%s.log" % name, linkname)
if self.image_statuses_unmatched:
LOG.debug("=====================================")