From 8e4c908b4c95df6073b67b36f458c504fe62a7a3 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Tue, 23 Oct 2018 17:00:19 +0200 Subject: [PATCH] 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 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 (cherry picked from commit 5792c1d7b44737f1f39bb1a81b0c95207ad087ad) --- kolla/image/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kolla/image/build.py b/kolla/image/build.py index 0a0c69b38c..98b42f2296 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -1037,9 +1037,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("=====================================")