Skip to contentSkip to conversation

[1.46][PATCH 0/5] Patch review

bitbake Steve Sakoman 1 participant 6 messages Jun 21, 2022

lore
Share & tools
lore
#0 lore raw

Please review this set of patches for 1.46/dunfell and have comments back by end of day Thursday/

Passed a-full on autobuilder:

https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/3805

The following changes since commit d8c2175f6a7b5fdf111d6a073b2c3dbd3c0b061d:

fetch2: add check for empty SRC_URI hash string (2022-04-05 20:49:37 +0100)

are available in the Git repository at:

git://git.openembedded.org/bitbake-contrib stable/1.46-nut
http://cgit.openembedded.org/bitbake-contrib/log/?h=stable/1.46-nut

Richard Purdie (3):
server/process: Disable gc around critical section tinfoil/data_smart: Allow variable history emit() to function remotely bin/bitbake-getvar: Add a new command to query a variable value (with
history)

Ross Burton (2):
knotty: display active tasks when printing keepAlive() message
knotty: reduce keep-alive timeout from 5000s (83 minutes) to 10
minutes

 bin/bitbake-getvar       | 48 ++++++++++++++++++++++++++++++++++++++++
 lib/bb/command.py        | 12 ++++++++++
 lib/bb/server/process.py |  3 +++
 lib/bb/tinfoil.py        |  4 ++++
 lib/bb/ui/knotty.py      | 11 +++++----
 5 files changed, 74 insertions(+), 4 deletions(-)
 create mode 100755 bin/bitbake-getvar
Signature · 1 line
2.25.1
#1 lore raw

[bitbake][dunfell][1.46][PATCH 1/5] server/process: Disable gc around critical section

From: Richard Purdie <[email protected]>

The python gc can trigger whilst we're holding the event stream lock and when cleaning up objects, they can trigger warnings. This translates into a new event which would then need the lock and we can deadlock.

Disable gc whilst we hold that lock to avoid this unfortunate and problematic situation.

(cherry picked from commit 96a6303949cefd469bcf5ed250ff512271354357)
---
 lib/bb/server/process.py | 3 +++
 1 file changed, 3 insertions(+)
lib/bb/server/process.py +3 -0
index 3c9ed706..4bdb84ae 100644
@@ -25,6 +25,7 @@ import subprocess
 import errno
 import re
 import datetime
+import gc
 import bb.server.xmlrpcserver
 from bb import daemonize
 from multiprocessing import queues
@@ -671,8 +672,10 @@ class ConnectionWriter(object):
 
     def send(self, obj):
         obj = multiprocessing.reduction.ForkingPickler.dumps(obj)
+        gc.disable()
         with self.wlock:
             self.writer.send_bytes(obj)
+        gc.enable()
 
     def fileno(self):
         return self.writer.fileno()
Signature · 1 line
2.25.1
#2 lore raw

[bitbake][dunfell][1.46][PATCH 4/5] knotty: display active tasks when printing keepAlive() message

In reply to Steve Sakoman

From: 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.

(cherry picked from commit 30f6c3f175617beea8e8bb75dcf255611e3fc2fd)
---
 lib/bb/ui/knotty.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/bb/ui/knotty.py +3 -1
index e70c2464..71c5a3e9 100644
@@ -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.25.1
#3 lore raw

[bitbake][dunfell][1.46][PATCH 3/5] bin/bitbake-getvar: Add a new command to query a variable value (with history)

In reply to Steve Sakoman

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]

(cherry picked from commit 4c1881b620e885f55d7772f8626b8a76c2828333)
---
 bin/bitbake-getvar | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 bin/bitbake-getvar
bin/bitbake-getvar new file +48 -0
new file mode 100755
index 00000000..94232192
@@ -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 args.recipe:
+            tinfoil.prepare(quiet=2)
+            d = tinfoil.parse_recipe(args.recipe)
+        else:
+            tinfoil.prepare(quiet=2, config_only=True)
+            d = tinfoil.config_data
+        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.25.1
#4 lore raw

[bitbake][dunfell][1.46][PATCH 2/5] tinfoil/data_smart: Allow variable history emit() to function remotely

In reply to Steve Sakoman

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.

(cherry picked from commit ba0fa084ccd2b1ade96425d158fd31e49e42f286)
---
 lib/bb/command.py | 12 ++++++++++++
 lib/bb/tinfoil.py |  4 ++++
 2 files changed, 16 insertions(+)
lib/bb/command.py +12 -0
index 98c945ed..b8429b27 100644
@@ -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
index 28f1e562..8bec8cba 100644
@@ -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.25.1
#5 lore raw

[bitbake][dunfell][1.46][PATCH 5/5] knotty: reduce keep-alive timeout from 5000s (83 minutes) to 10 minutes

In reply to Steve Sakoman

From: 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.

(cherry picked from commit dcf52157d3635925491783be656c6b76d1efe1a4)
---
 lib/bb/ui/knotty.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
lib/bb/ui/knotty.py +4 -3
index 71c5a3e9..d1f74389 100644
@@ -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.25.1