Skip to contentSkip to conversation

tinfoil: Drop parse_recipe_file custom datastore support

PATCH New Richard Purdie 1 participant 3 messages Mar 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tinfoil: Drop parse_recipe_file custom datastore support

This parameter is unused except for a single selftest and is problematic with regard to fixing some other bugs. Remove it for now, if really needed we could re-implement it in some other way in the future. Experience tells us we likely don't want to support this kind of change to the metadata anyway as its not as useful as it first sounds/appears.

---
 lib/bb/tinfoil.py | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
lib/bb/tinfoil.py +2 -9
index a8e835d29c..70b381e351 100644
@@ -615,7 +615,7 @@ class Tinfoil:
         fn = self.get_recipe_file(pn)
         return self.parse_recipe_file(fn)
 
-    def parse_recipe_file(self, fn, appends=True, appendlist=None, config_data=None):
+    def parse_recipe_file(self, fn, appends=True, appendlist=None):
         """
         Parse the specified recipe file (with or without bbappends)
         and return a datastore object representing the environment
@@ -626,9 +626,6 @@ class Tinfoil:
             appends: True to apply bbappends, False otherwise
             appendlist: optional list of bbappend files to apply, if you
                         want to filter them
-            config_data: custom config datastore to use. NOTE: if you
-                         specify config_data then you cannot use a virtual
-                         specification for fn.
         """
         if self.tracking:
             # Enable history tracking just for the parse operation
@@ -636,11 +633,7 @@ class Tinfoil:
         try:
             if appends and appendlist == []:
                 appends = False
-            if config_data:
-                dctr = bb.remotedata.RemoteDatastores.transmit_datastore(config_data)
-                dscon = self.run_command('parseRecipeFile', fn, appends, appendlist, dctr)
-            else:
-                dscon = self.run_command('parseRecipeFile', fn, appends, appendlist)
+            dscon = self.run_command('parseRecipeFile', fn, appends, appendlist)
             if dscon:
                 return self._reconvert_type(dscon, 'DataStoreConnectionHandle')
             else:
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 data_smart: Don't pass unneeded datastore

The datastore is already available to this function internally so don't also try and pass the datastore as a parameter. This is clearly broken API when you look at the existing calls to it.

This then doesn't break the planned tinfoil data connector changes.

---
 lib/bb/data_smart.py        | 3 ++-
 lib/bblayers/common.py      | 2 +-
 lib/layerindexlib/cooker.py | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
lib/bb/data_smart.py +2 -1
index 63a32bc6a7..b2dc9d9fd5 100644
@@ -338,11 +338,12 @@ class VariableHistory(object):
                 lines.append(line)
         return lines
 
-    def get_variable_items_files(self, var, d):
+    def get_variable_items_files(self, var):
         """
         Use variable history to map items added to a list variable and
         the files in which they were added.
         """
+        d = self.dataroot
         history = self.variable(var)
         finalitems = (d.getVar(var) or '').split()
         filemap = {}
lib/bblayers/common.py +1 -1
index c5657d3819..6c76ef3505 100644
@@ -17,7 +17,7 @@ class LayerPlugin():
     def tinfoil_init(self, tinfoil):
         self.tinfoil = tinfoil
         self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split()
-        layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', self.tinfoil.config_data)
+        layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS')
         self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()}
 
     @staticmethod
lib/layerindexlib/cooker.py +1 -1
index 4ce397d884..65b23d087f 100644
@@ -93,7 +93,7 @@ class CookerPlugin(layerindexlib.plugin.IndexPlugin):
             return index
 
         collections = d.getVar('BBFILE_COLLECTIONS')
-        layerconfs = d.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', d)
+        layerconfs = d.varhistory.get_variable_items_files('BBFILE_COLLECTIONS')
         bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()}
 
         (_, bb_branch, _, _) = self._get_bitbake_info()
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 tinfoil: Simplify remote datastore connections

In reply to Richard Purdie

The current approach to remote datastores used in tinfoil is breaking. For example, adding a devupstream extension to a recipe with a git upstream, making it the preferred version and then running "devtool modify" on it causes get_srcrev() circular dependency issues. The problem is the override handling in the datastore is broken.

This gets broken since remotedata:recieve_datastore() sets d.dict but doesn't update d.overridedata (or d.inchistory or d.varhistory). We could play whack-a-mole but the current implementation seems to be flawed to me. It also doesn't cover, or only partially covers some datastore operations and each needs new dedicated command API.

Instead, step back and reimplement the way the datastore connector works.

With this change, the datastore is either remote or local but the data is not spread on two sides of the connection. All the API is proxied over the connection by a single function for the datastore (and two to support variable history and include history).

This code does not support using the datastore as a parameter to any data store functions. We did have one case of that but its just bad code and can be replaced.

The result is something which is much simpler and less invasive to the datastore code itself, meaning its behaviour should be much more consistent. The existing tests for the remote data no longer make any sense and are removed.

The one bug this code would have is if key/value pairs are returned over the IPC and those values contained a DataSmart object since we don't recurse into return values to find such things. Nothing appears to do that currently so lets worry about it if its ever an issue. This change should simplfy a ton of other issues and avoid a ton of other bugs so is a huge net gain.

Tested with bitbake's and OE's selftests.

---
 lib/bb/command.py    |  91 ++++++++--------------------
 lib/bb/data_smart.py |  53 +----------------
 lib/bb/remotedata.py |  47 +--------------
 lib/bb/tests/data.py | 139 -------------------------------------------
 lib/bb/tinfoil.py    | 118 ++++++++++++++++++------------------
 5 files changed, 88 insertions(+), 360 deletions(-)
lib/bb/command.py +25 -66
index b38c151b3d..2879950933 100644
@@ -450,54 +450,38 @@ class CommandsSync:
         return all_p, best
     getRuntimeProviders.readonly = True
 
-    def dataStoreConnectorFindVar(self, command, params):
+    def dataStoreConnectorCmd(self, command, params):
         dsindex = params[0]
-        name = params[1]
-        datastore = command.remotedatastores[dsindex]
-        value, overridedata = datastore._findVar(name)
-
-        if value:
-            content = value.get('_content', None)
-            if isinstance(content, bb.data_smart.DataSmart):
-                # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully
-                idx = command.remotedatastores.check_store(content, True)
-                return {'_content': DataStoreConnectionHandle(idx),
-                        '_connector_origtype': 'DataStoreConnectionHandle',
-                        '_connector_overrides': overridedata}
-            elif isinstance(content, set):
-                return {'_content': list(content),
-                        '_connector_origtype': 'set',
-                        '_connector_overrides': overridedata}
-            else:
-                value['_connector_overrides'] = overridedata
-        else:
-            value = {}
-            value['_connector_overrides'] = overridedata
-        return value
-    dataStoreConnectorFindVar.readonly = True
+        method = params[1]
+        args = params[2]
+        kwargs = params[3]
 
-    def dataStoreConnectorGetKeys(self, command, params):
-        dsindex = params[0]
-        datastore = command.remotedatastores[dsindex]
-        return list(datastore.keys())
-    dataStoreConnectorGetKeys.readonly = True
+        d = command.remotedatastores[dsindex]
+        ret = getattr(d, method)(*args, **kwargs)
+
+        if isinstance(ret, bb.data_smart.DataSmart):
+            idx = command.remotedatastores.store(ret)
+            return DataStoreConnectionHandle(idx)
 
-    def dataStoreConnectorGetVarHistory(self, command, params):
+        return ret
+
+    def dataStoreConnectorVarHistCmd(self, command, params):
         dsindex = params[0]
-        name = params[1]
-        datastore = command.remotedatastores[dsindex]
-        return datastore.varhistory.variable(name)
-    dataStoreConnectorGetVarHistory.readonly = True
+        method = params[1]
+        args = params[2]
+        kwargs = params[3]
 
-    def dataStoreConnectorExpandPythonRef(self, command, params):
-        config_data_dict = params[0]
-        varname = params[1]
-        expr = params[2]
+        d = command.remotedatastores[dsindex].varhistory
+        return getattr(d, method)(*args, **kwargs)
 
-        config_data = command.remotedatastores.receive_datastore(config_data_dict)
+    def dataStoreConnectorIncHistCmd(self, command, params):
+        dsindex = params[0]
+        method = params[1]
+        args = params[2]
+        kwargs = params[3]
 
-        varparse = bb.data_smart.VariableParse(varname, config_data)
-        return varparse.python_sub(expr)
+        d = command.remotedatastores[dsindex].inchistory
+        return getattr(d, method)(*args, **kwargs)
 
     def dataStoreConnectorRelease(self, command, params):
         dsindex = params[0]
@@ -505,31 +489,6 @@ class CommandsSync:
             raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex)
         command.remotedatastores.release(dsindex)
 
-    def dataStoreConnectorSetVarFlag(self, command, params):
-        dsindex = params[0]
-        name = params[1]
-        flag = params[2]
-        value = params[3]
-        datastore = command.remotedatastores[dsindex]
-        datastore.setVarFlag(name, flag, value)
-
-    def dataStoreConnectorDelVar(self, command, params):
-        dsindex = params[0]
-        name = params[1]
-        datastore = command.remotedatastores[dsindex]
-        if len(params) > 2:
-            flag = params[2]
-            datastore.delVarFlag(name, flag)
-        else:
-            datastore.delVar(name)
-
-    def dataStoreConnectorRenameVar(self, command, params):
-        dsindex = params[0]
-        name = params[1]
-        newname = params[2]
-        datastore = command.remotedatastores[dsindex]
-        datastore.renameVar(name, newname)
-
     def parseRecipeFile(self, command, params):
         """
         Parse the specified recipe file (with or without bbappends)
lib/bb/data_smart.py +3 -50

119 lines not on this page · raw message

lib/bb/remotedata.py +2 -45

62 lines not on this page · raw message

lib/bb/tests/data.py +0 -139

142 lines not on this page · raw message

lib/bb/tinfoil.py +58 -60

148 lines not on this page · raw message

Signature · 1 line
2.25.1