AnalyzeBuildLogs(): only analyze one file at a time
Will be used in a follow-up commit to simplify analysis of log files and HTML file printing.
This commit is contained in:
@@ -412,12 +412,13 @@ class Cluster:
|
|||||||
self.cmd.close()
|
self.cmd.close()
|
||||||
|
|
||||||
# Analyze the logs
|
# Analyze the logs
|
||||||
collectInfo = cls_containerize.AnalyzeBuildLogs(log_files, status)
|
collectInfo = {}
|
||||||
for img in collectInfo:
|
for image, lf in log_files:
|
||||||
for f in collectInfo[img]:
|
files = {}
|
||||||
status = status and collectInfo[img][f]['status']
|
idx = 'Target Image Creation'
|
||||||
if not status:
|
files[idx] = cls_containerize.AnalyzeBuildLogs(image, lf)
|
||||||
logging.debug(collectInfo)
|
status = status and files[idx]['status']
|
||||||
|
collectInfo[image] = files
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m')
|
logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m')
|
||||||
|
|||||||
@@ -82,28 +82,23 @@ def CreateTag(ranCommitID, ranBranch, ranAllowMerge):
|
|||||||
tagToUse = f'develop-{shortCommit}'
|
tagToUse = f'develop-{shortCommit}'
|
||||||
return tagToUse
|
return tagToUse
|
||||||
|
|
||||||
def AnalyzeBuildLogs(logfiles, globalStatus):
|
def AnalyzeBuildLogs(image, lf):
|
||||||
collectInfo = {}
|
errorandwarnings = {}
|
||||||
for image, lf in logfiles:
|
committed = False
|
||||||
files = {}
|
tagged = False
|
||||||
errorandwarnings = {}
|
with open(lf, mode='r') as inputfile:
|
||||||
committed = False
|
for line in inputfile:
|
||||||
tagged = False
|
lineHasTag = re.search(f'Successfully tagged {image}:', str(line)) is not None
|
||||||
with open(lf, mode='r') as inputfile:
|
lineHasTag2 = re.search(f'naming to docker.io/library/{image}:', str(line)) is not None
|
||||||
for line in inputfile:
|
tagged = tagged or lineHasTag or lineHasTag2
|
||||||
lineHasTag = re.search(f'Successfully tagged {image}:', str(line)) is not None
|
# the OpenShift Cluster builder prepends image registry URL
|
||||||
lineHasTag2 = re.search(f'naming to docker.io/library/{image}:', str(line)) is not None
|
lineHasCommit = re.search(r'COMMIT [a-zA-Z0-9\.:/\-]*' + image, str(line)) is not None
|
||||||
tagged = tagged or lineHasTag or lineHasTag2
|
committed = committed or lineHasCommit
|
||||||
# the OpenShift Cluster builder prepends image registry URL
|
errorandwarnings['errors'] = 0 if committed or tagged else 1
|
||||||
lineHasCommit = re.search(r'COMMIT [a-zA-Z0-9\.:/\-]*' + image, str(line)) is not None
|
errorandwarnings['warnings'] = 0
|
||||||
committed = committed or lineHasCommit
|
errorandwarnings['status'] = committed or tagged
|
||||||
errorandwarnings['errors'] = 0 if committed or tagged else 1
|
logging.info(f"Analyzing {image}, file {lf}: {errorandwarnings}")
|
||||||
errorandwarnings['warnings'] = 0
|
return errorandwarnings
|
||||||
errorandwarnings['status'] = committed or tagged
|
|
||||||
logging.info(f"Analyzing {image}, file {lf}: {errorandwarnings}")
|
|
||||||
files['Target Image Creation'] = errorandwarnings
|
|
||||||
collectInfo[image] = files
|
|
||||||
return collectInfo
|
|
||||||
|
|
||||||
def GetImageName(ssh, svcName, file):
|
def GetImageName(ssh, svcName, file):
|
||||||
ret = ssh.run(f"docker compose -f {file} config --format json {svcName} | jq -r '.services.\"{svcName}\".image'", silent=True)
|
ret = ssh.run(f"docker compose -f {file} config --format json {svcName} | jq -r '.services.\"{svcName}\".image'", silent=True)
|
||||||
@@ -467,7 +462,13 @@ class Containerize():
|
|||||||
cmd.close()
|
cmd.close()
|
||||||
|
|
||||||
# Analyze the logs
|
# Analyze the logs
|
||||||
collectInfo = AnalyzeBuildLogs(log_files, status)
|
collectInfo = {}
|
||||||
|
for name, lf in log_files:
|
||||||
|
files = {}
|
||||||
|
idx = 'Target Image Creation'
|
||||||
|
files[idx] = AnalyzeBuildLogs(name, lf)
|
||||||
|
status = status and files[idx]['status']
|
||||||
|
collectInfo[name] = files
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m')
|
logging.info('\u001B[1m Building OAI Image(s) Pass\u001B[0m')
|
||||||
|
|||||||
Reference in New Issue
Block a user