[1.46][PATCH 1/4] tinfoil/data_smart: Allow variable history emit() to function remotely
From: Richard Purdie <[email protected]>
We can't access the emit() function of varhistory currently as the datastore parameter isn't handled correctly, nor is the output stream. Add a custom wrapper for this function which handles the two details correctly.
--- lib/bb/command.py | 12 ++++++++++++ lib/bb/tinfoil.py | 4 ++++ 2 files changed, 16 insertions(+)
lib/bb/command.py +12 -0
@@ -20,6 +20,7 @@ Commands are queued in a CommandQueue from collections import OrderedDict, defaultdict +import io import bb.event import bb.cooker import bb.remotedata
@@ -478,6 +479,17 @@ class CommandsSync: d = command.remotedatastores[dsindex].varhistory return getattr(d, method)(*args, **kwargs) + def dataStoreConnectorVarHistCmdEmit(self, command, params): + dsindex = params[0] + var = params[1] + oval = params[2] + val = params[3] + d = command.remotedatastores[params[4]] + + o = io.StringIO() + command.remotedatastores[dsindex].varhistory.emit(var, oval, val, o, d) + return o.getvalue() + def dataStoreConnectorIncHistCmd(self, command, params): dsindex = params[0] method = params[1]
lib/bb/tinfoil.py +4 -0
@@ -53,6 +53,10 @@ class TinfoilDataStoreConnectorVarHistory: def remoteCommand(self, cmd, *args, **kwargs): return self.tinfoil.run_command('dataStoreConnectorVarHistCmd', self.dsindex, cmd, args, kwargs) + def emit(self, var, oval, val, o, d): + ret = self.tinfoil.run_command('dataStoreConnectorVarHistCmdEmit', self.dsindex, var, oval, val, d.dsindex) + o.write(ret) + def __getattr__(self, name): if not hasattr(bb.data_smart.VariableHistory, name): raise AttributeError("VariableHistory has no such method %s" % name)
Signature · 1 line
2.35.1
[1.46][PATCH 2/4] bin/bitbake-getvar: Add a new command to query a variable value (with history)
From: Richard Purdie <[email protected]>
We've talked about having this for long enough. Add a command which queries a single variable value with history. This saves "bitbake -e | grep" and avoids the various pitfalls that has.
It also provides a neat example of using tinfoil to make such a query.
Parameters to limit the output to just the value, to limit to a variable flag and to not expand the output are provided.
[YOCTO #10748]
--- bin/bitbake-getvar | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 bin/bitbake-getvar
bin/bitbake-getvar new file +48 -0
@@ -0,0 +1,48 @@ +#! /usr/bin/env python3 +# +# Copyright (C) 2021 Richard Purdie +# +# SPDX-License-Identifier: GPL-2.0-only +# + +import argparse +import io +import os +import sys + +bindir = os.path.dirname(__file__) +topdir = os.path.dirname(bindir) +sys.path[0:0] = [os.path.join(topdir, 'lib')] + +import bb.tinfoil + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Bitbake Query Variable") + parser.add_argument("variable", help="variable name to query") + parser.add_argument("-r", "--recipe", help="Recipe name to query", default=None, required=False) + parser.add_argument('-u', '--unexpand', help='Do not expand the value (with --value)', action="store_true") + parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None) + parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true") + args = parser.parse_args() + + if args.unexpand and not args.value: + print("--unexpand only makes sense with --value") + sys.exit(1) + + if args.flag and not args.value: + print("--flag only makes sense with --value") + sys.exit(1) + + with bb.tinfoil.Tinfoil(tracking=True) as tinfoil: + if not args.recipe: + tinfoil.prepare(quiet=2, config_only=True) + d = tinfoil.config_data + else: + tinfoil.prepare(quiet=2) + d = tinfoil.parse_recipe(args.recipe) + if args.flag: + print(str(d.getVarFlag(args.variable, args.flag, expand=(not args.unexpand)))) + elif args.value: + print(str(d.getVar(args.variable, expand=(not args.unexpand)))) + else: + bb.data.emit_var(args.variable, d=d, all=True)
Signature · 1 line
2.35.1
[1.46][PATCH 3/4] knotty: display active tasks when printing keepAlive() message
In reply to Martin JansaFrom: Ross Burton <[email protected]>
In interactive bitbake sessions it is obvious what tasks are running when one of them hangs or otherwise takes a long time. However, in non-interactive sessions (such as automated builds) bitbake just prints a message saying that it is "still alive" with no clues as to what tasks are active still.
By simply listing the active tasks when printing the keep alive message, we don't need to parse the bitbake log to identify which of the tasks is still active and has presumably hung.
--- lib/bb/ui/knotty.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/bb/ui/knotty.py +3 -1
@@ -227,7 +227,9 @@ class TerminalFilter(object): def keepAlive(self, t): if not self.cuu: - print("Bitbake still alive (%ds)" % t) + print("Bitbake still alive (no events for %ds). Active tasks:" % t) + for t in self.helper.running_tasks: + print(t) sys.stdout.flush() def updateFooter(self):
Signature · 1 line
2.35.1
[1.46][PATCH 4/4] knotty: reduce keep-alive timeout from 5000s (83 minutes) to 10 minutes
In reply to Martin JansaFrom: Ross Burton <[email protected]>
The keep alive timeout is excessively long at 83 minutes (5000 seconds), reduce this to 10 minutes: this should be long enough that it rarely triggers in normal builds, but when it does it has useful information.
--- lib/bb/ui/knotty.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
lib/bb/ui/knotty.py +4 -3
@@ -599,7 +599,8 @@ def main(server, eventHandler, params, tf = TerminalFilter): warnings = 0 taskfailures = [] - printinterval = 5000 + printintervaldelta = 10 * 60 # 10 minutes + printinterval = printintervaldelta lastprint = time.time() termfilter = tf(main, helper, console_handlers, params.options.quiet)
@@ -609,7 +610,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): try: if (lastprint + printinterval) <= time.time(): termfilter.keepAlive(printinterval) - printinterval += 5000 + printinterval += printintervaldelta event = eventHandler.waitEvent(0) if event is None: if main.shutdown > 1:
@@ -640,7 +641,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): if isinstance(event, logging.LogRecord): lastprint = time.time() - printinterval = 5000 + printinterval = printintervaldelta if event.levelno >= bb.msg.BBLogFormatter.ERROR: errors = errors + 1 return_value = 1
Signature · 1 line
2.35.1