Skip to contentSkip to conversation

A couple of fixes

PATCH New Paul Eggleton 1 participant 3 messages Sep 11, 2017

lore
Share & tools
lore
#0 lore raw

cover A couple of fixes

The following changes since commit ed3aab90dbf9b6efefd9eb66d81123cb94d3c7da:

toaster: update pyro to rocko as stable release (2017-09-11 11:00:11 +0100)

are available in the git repository at:

git://git.openembedded.org/bitbake-contrib paule/bb-fixes
http://cgit.openembedded.org/bitbake-contrib/log/?h=paule/bb-fixes

Paul Eggleton (2):
runqueue: fix BB_SETSCENE_ENFORCE with empty BB_SETSCENE_ENFORCE_WHITELIST server/process: ensure server failure log is limited to current session

 lib/bb/runqueue.py       |  6 +++---
 lib/bb/server/process.py | 28 +++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.5
#1 lore raw

PATCH 1/2 runqueue: fix BB_SETSCENE_ENFORCE with empty BB_SETSCENE_ENFORCE_WHITELIST

The whitelist shouldn't have to be populated in order for the enforcement to work properly - check if the list is not None in order to determine whether the functionality is enabled or not since that is how the function that sets up the list behaves.

---
 lib/bb/runqueue.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/bb/runqueue.py +3 -3
index 6b3a0fc..ae12c25 100644
@@ -1834,7 +1834,7 @@ class RunQueueExecuteTasks(RunQueueExecute):
         Run the tasks in a queue prepared by rqdata.prepare()
         """
 
-        if self.rqdata.setscenewhitelist and not self.rqdata.setscenewhitelist_checked:
+        if self.rqdata.setscenewhitelist is not None and not self.rqdata.setscenewhitelist_checked:
             self.rqdata.setscenewhitelist_checked = True
 
             # Check tasks that are going to run against the whitelist
@@ -2249,7 +2249,7 @@ class RunQueueExecuteScenequeue(RunQueueExecute):
         self.scenequeue_updatecounters(task)
 
     def check_taskfail(self, task):
-        if self.rqdata.setscenewhitelist:
+        if self.rqdata.setscenewhitelist is not None:
             realtask = task.split('_setscene')[0]
             (mc, fn, taskname, taskfn) = split_tid_mcfn(realtask)
             pn = self.rqdata.dataCaches[mc].pkg_fn[taskfn]
@@ -2603,7 +2603,7 @@ def get_setscene_enforce_whitelist(d):
 
 def check_setscene_enforce_whitelist(pn, taskname, whitelist):
     import fnmatch
-    if whitelist:
+    if whitelist is not None:
         item = '%s:%s' % (pn, taskname)
         for whitelist_item in whitelist:
             if fnmatch.fnmatch(item, whitelist_item):
Signature · 1 line
2.9.5
#2 lore raw

PATCH 2/2 server/process: ensure server failure log is limited to current session

In reply to Paul Eggleton

Printing the last 10 lines of bitbake-cookerdaemon.log when the server fails to start can sometimes result in printing the output from a previous run, which could lead the user completely down the wrong path in terms of the cause of the failure. Use a known start text containing the time which we can then look for when scanning through the log, and then grab the last 10 lines of that part instead.

Fixes [YOCTO #11903].

---
 lib/bb/server/process.py | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
lib/bb/server/process.py +25 -3
index 5c7dfae..e64194d 100644
@@ -33,6 +33,8 @@ import select
 import socket
 import subprocess
 import errno
+import re
+import datetime
 import bb.server.xmlrpcserver
 from bb import daemonize
 from multiprocessing import queues
@@ -358,6 +360,9 @@ class BitBakeProcessServerConnection(object):
         return
 
 class BitBakeServer(object):
+    start_log_format = '--- Starting bitbake server pid %s at %s ---'
+    start_log_datetime_format = '%Y-%m-%d %H:%M:%S.%f'
+
     def __init__(self, lock, sockname, configuration, featureset):
 
         self.configuration = configuration
@@ -383,6 +388,7 @@ class BitBakeServer(object):
         self.sock.listen(1)
 
         os.set_inheritable(self.sock.fileno(), True)
+        startdatetime = datetime.datetime.now()
         bb.daemonize.createDaemon(self._startServer, logfile)
         self.sock.close()
         self.bitbake_lock.close()
@@ -393,15 +399,31 @@ class BitBakeServer(object):
             ready.close()
             bb.error("Unable to start bitbake server")
             if os.path.exists(logfile):
+                logstart_re = re.compile(self.start_log_format % ('([0-9]+)', '([0-9-]+ [0-9:.]+)'))
+                started = False
+                lines = []
                 with open(logfile, "r") as f:
-                    logs=f.readlines()
-                bb.error("Last 10 lines of server log %s:\n%s" % (logfile, "".join(logs[-10:])))
+                    for line in f:
+                        if started:
+                            lines.append(line)
+                        else:
+                            res = logstart_re.match(line.rstrip())
+                            if res:
+                                ldatetime = datetime.datetime.strptime(res.group(2), self.start_log_datetime_format)
+                                if ldatetime >= startdatetime:
+                                    started = True
+                                    lines.append(line)
+                if lines:
+                    if len(lines) > 10:
+                        bb.error("Last 10 lines of server log for this session (%s):\n%s" % (logfile, "".join(lines[-10:])))
+                    else:
+                        bb.error("Server log for this session (%s):\n%s" % (logfile, "".join(lines)))
             raise SystemExit(1)
         ready.close()
         os.close(self.readypipein)
 
     def _startServer(self):
-        print("Starting bitbake server pid %d" % os.getpid())
+        print(self.start_log_format % (os.getpid(), datetime.datetime.now().strftime(self.start_log_datetime_format)))
         server = ProcessServer(self.bitbake_lock, self.sock, self.sockname)
         self.configuration.setServerRegIdleCallback(server.register_idle_function)
 
Signature · 1 line
2.9.5