Skip to content

Commit 5cfdfd1

Browse files
committed
[bugfix] Cover edge cases with indistinguishable error log paths
- In testing multiple failures can occur in quick succession resulting in the same time stamp, and as a result in the same base error log path. Extent the path stamp with an increasing number (naive O(n^2) algorithm used at the moment, should be sufficient). - In case the user provides the same error log path as the build directory log path, add a check to prevent copying the files to prevent errors in the copying functions.
1 parent d0aae3a commit 5cfdfd1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

easybuild/framework/easyblock.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,13 @@ def print_dry_run_note(loc, silent=True):
41984198

41994199

42004200
def persists_failed_compilation_log_and_artifacts(build_successful, application_log, silent, app, err_log_path):
4201+
def do_if_paths_distinct(operation, source, destination):
4202+
if not os.path.exists(source):
4203+
return
4204+
if os.path.realpath(source) == os.path.realpath(destination):
4205+
return
4206+
operation(source, destination)
4207+
42014208
if application_log:
42024209
# there may be multiple log files, or the file name may be different due to zipping
42034210
logs = glob.glob('%s*' % application_log)
@@ -4210,12 +4217,12 @@ def persists_failed_compilation_log_and_artifacts(build_successful, application_
42104217
if err_log_path and not build_successful:
42114218
for log_file in logs:
42124219
target_file = os.path.join(err_log_path, os.path.basename(log_file))
4213-
copy_file(log_file, target_file)
4220+
do_if_paths_distinct(copy_file, log_file, target_file)
42144221

42154222
builddir = app.builddir
42164223
if is_readable(builddir):
42174224
build_artifact_log_path = os.path.join(err_log_path, app.get_relative_builddir_base_path())
4218-
copy_dir(builddir, build_artifact_log_path)
4225+
do_if_paths_distinct(copy_dir, builddir, build_artifact_log_path)
42194226

42204227
print_msg(
42214228
"Build log and any output artifacts copied to permanent storage: %s" % err_log_path,

easybuild/tools/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,15 @@ def error_log_path(ec=None):
861861
date = time.strftime("%Y%m%d")
862862
timestamp = time.strftime("%H%M%S")
863863

864-
return '/'.join([error_log_path, name + '-' + version, date + '-' + timestamp])
864+
base_path = '/'.join([error_log_path, name + '-' + version, date + '-' + timestamp])
865+
866+
path = base_path
867+
inc_no = 1
868+
while os.path.exists(path):
869+
path = base_path + '_' + str(inc_no)
870+
inc_no += 1
871+
872+
return path
865873

866874

867875
def get_build_log_path():

0 commit comments

Comments
 (0)