runconfig/observer: Simplify log handling for new format tasks

For new tasks, hide errors/warnings if not present, don't monitor steyXY
logfiles as they're no longer needed and ensure description is provided
by our code as shellCommand doesn't handle it.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2020-11-12 08:27:45 +00:00
parent 2c17ca10da
commit 7898d68ccc
3 changed files with 25 additions and 15 deletions

View File

@ -4,7 +4,6 @@ from yoctoabb import config
from yoctoabb.steps.writelayerinfo import WriteLayerInfo
from yoctoabb.steps.runconfig import get_publish_dest, get_publish_resultdir, get_publish_name, RunConfigCheckSteps
from buildbot.process.results import Results, SUCCESS, FAILURE, CANCELLED, WARNINGS, SKIPPED, EXCEPTION, RETRY
from yoctoabb.steps.observer import RunConfigLogObserver
from twisted.python import log

View File

@ -13,23 +13,25 @@ from functools import partial
# Monitor the step 1-X logs and stdio, collecting up any warnings and errors seen
# and publish them at the end in their own 'logfile' for ease of access to the user
#
class RunConfigLogObserver(ShellCommand):
class SimpleLogObserver(ShellCommand):
warnOnWarnings = True
warnOnFailure = True
warnings = 0
errors = 0
def __init__(self, python=None, maxsteps=10, *args, **kwargs):
ShellCommand.__init__(self, *args, **kwargs)
self.python = python
def __init__(self, maxsteps=10, *args, **kwargs):
super().__init__(*args, **kwargs)
self.warningLines = []
self.errorLines = []
if "description" in kwargs:
self.description = kwargs["description"]
else:
self.description = "run-config"
self.addLogObserver('stdio', logobserver.LineConsumerLogObserver(partial(self.logConsumer, 'stdio')))
for i in range(1, maxsteps):
for j in ['a', 'b', 'c', 'd']:
name = 'step' + str(i) + str(j)
self.addLogObserver(name, logobserver.LineConsumerLogObserver(partial(self.logConsumer, name)))
def describe(self, done=False):
return self.description
def logConsumer(self, logname):
while True:
@ -42,8 +44,10 @@ class RunConfigLogObserver(ShellCommand):
self.errorLines.append(logname + ": " + line)
def commandComplete(self, cmd):
self.addCompleteLog('warnings', '\n'.join(self.warningLines))
self.addCompleteLog('errors', '\n'.join(self.errorLines))
if self.warningLines:
self.addCompleteLog('warnings', '\n'.join(self.warningLines))
if self.errorLines:
self.addCompleteLog('errors', '\n'.join(self.errorLines))
def evaluateCommand(self, cmd):
if cmd.didFail() or self.errors:
@ -51,3 +55,12 @@ class RunConfigLogObserver(ShellCommand):
if self.warnings:
return WARNINGS
return SUCCESS
class RunConfigLogObserver(SimpleLogObserver):
def __init__(self, maxsteps=10, *args, **kwargs):
super().__init__(*args, **kwargs)
for i in range(1, maxsteps):
for j in ['a', 'b', 'c', 'd']:
name = 'step' + str(i) + str(j)
self.addLogObserver(name, logobserver.LineConsumerLogObserver(partial(self.logConsumer, name)))

View File

@ -4,7 +4,7 @@ from buildbot.process import buildstep, logobserver
from buildbot.process.results import Results, SUCCESS, FAILURE, CANCELLED, WARNINGS, SKIPPED, EXCEPTION, RETRY
from buildbot.steps import shell
from yoctoabb.steps.observer import RunConfigLogObserver
from yoctoabb.steps.observer import RunConfigLogObserver, SimpleLogObserver
import json
import datetime
@ -141,13 +141,11 @@ def get_runconfig_legacy_step(posttrigger):
return step
def get_runconfig_step(name, stepname, phase, description, posttrigger):
step = RunConfigLogObserver(
step = SimpleLogObserver(
command=get_runconfig_command(posttrigger) + ['--stepname', stepname, '--phase', phase],
name=name,
description=description,
logfiles=get_buildlogs(maxsteps),
lazylogfiles=True,
maxsteps=maxsteps,
timeout=16200) # default of 1200s/20min is too short, use 4.5hrs
return step