diff options
| author | Paul Barker <pbarker@konsulko.com> | 2021-02-05 11:26:11 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-02-10 23:48:16 +0000 |
| commit | 73160aac0608cc186be1ec991b08ff8f130cdb8f (patch) | |
| tree | a4b9d783b02e6efb4f715a7797b4f9fd47477291 /bitbake | |
| parent | 94f34b951bedaf7c64ba61c07144bc42cc8e9937 (diff) | |
| download | poky-73160aac0608cc186be1ec991b08ff8f130cdb8f.tar.gz | |
bitbake: hashserv: server: Support searching upstream for outhash
Use the new get-outhash message to perform a read-only query against an
upstream server (if present) when a reported taskhash/outhash
combination is not found in the current database. If a matching entry is
found upstream it is copied into the current database so it can be found
by future queries.
(Bitbake rev: 2be4f7f0d2ccb09917398289e8140e1467e84bb2)
Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/hashserv/server.py | 20 | ||||
| -rw-r--r-- | bitbake/lib/hashserv/tests.py | 12 |
2 files changed, 32 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py index 2770c23607..9ade988e56 100644 --- a/bitbake/lib/hashserv/server.py +++ b/bitbake/lib/hashserv/server.py | |||
| @@ -130,6 +130,18 @@ async def copy_from_upstream(client, db, method, taskhash): | |||
| 130 | d = {k: v for k, v in d.items() if k in TABLE_COLUMNS} | 130 | d = {k: v for k, v in d.items() if k in TABLE_COLUMNS} |
| 131 | keys = sorted(d.keys()) | 131 | keys = sorted(d.keys()) |
| 132 | 132 | ||
| 133 | with closing(db.cursor()) as cursor: | ||
| 134 | insert_task(cursor, d) | ||
| 135 | db.commit() | ||
| 136 | |||
| 137 | return d | ||
| 138 | |||
| 139 | async def copy_outhash_from_upstream(client, db, method, outhash, taskhash): | ||
| 140 | d = await client.get_outhash(method, outhash, taskhash) | ||
| 141 | if d is not None: | ||
| 142 | # Filter out unknown columns | ||
| 143 | d = {k: v for k, v in d.items() if k in TABLE_COLUMNS} | ||
| 144 | keys = sorted(d.keys()) | ||
| 133 | 145 | ||
| 134 | with closing(db.cursor()) as cursor: | 146 | with closing(db.cursor()) as cursor: |
| 135 | insert_task(cursor, d) | 147 | insert_task(cursor, d) |
| @@ -359,6 +371,14 @@ class ServerClient(object): | |||
| 359 | 371 | ||
| 360 | row = cursor.fetchone() | 372 | row = cursor.fetchone() |
| 361 | 373 | ||
| 374 | if row is None and self.upstream_client: | ||
| 375 | # Try upstream | ||
| 376 | row = await copy_outhash_from_upstream(self.upstream_client, | ||
| 377 | self.db, | ||
| 378 | data['method'], | ||
| 379 | data['outhash'], | ||
| 380 | data['taskhash']) | ||
| 381 | |||
| 362 | # If no matching outhash was found, or one *was* found but it | 382 | # If no matching outhash was found, or one *was* found but it |
| 363 | # wasn't an exact match on the taskhash, a new entry for this | 383 | # wasn't an exact match on the taskhash, a new entry for this |
| 364 | # taskhash should be added | 384 | # taskhash should be added |
diff --git a/bitbake/lib/hashserv/tests.py b/bitbake/lib/hashserv/tests.py index 6f04e30d61..1a696481e3 100644 --- a/bitbake/lib/hashserv/tests.py +++ b/bitbake/lib/hashserv/tests.py | |||
| @@ -246,6 +246,18 @@ class HashEquivalenceCommonTests(object): | |||
| 246 | self.assertClientGetHash(side_client, taskhash4, unihash4) | 246 | self.assertClientGetHash(side_client, taskhash4, unihash4) |
| 247 | self.assertClientGetHash(self.client, taskhash4, None) | 247 | self.assertClientGetHash(self.client, taskhash4, None) |
| 248 | 248 | ||
| 249 | # Test that reporting a unihash in the downstream is able to find a | ||
| 250 | # match which was previously reported to the upstream server | ||
| 251 | taskhash5 = '35788efcb8dfb0a02659d81cf2bfd695fb30faf9' | ||
| 252 | outhash5 = '2765d4a5884be49b28601445c2760c5f21e7e5c0ee2b7e3fce98fd7e5970796f' | ||
| 253 | unihash5 = 'f46d3fbb439bd9b921095da657a4de906510d2cd' | ||
| 254 | result = self.client.report_unihash(taskhash5, self.METHOD, outhash5, unihash5) | ||
| 255 | |||
| 256 | taskhash6 = '35788efcb8dfb0a02659d81cf2bfd695fb30fafa' | ||
| 257 | unihash6 = 'f46d3fbb439bd9b921095da657a4de906510d2ce' | ||
| 258 | result = down_client.report_unihash(taskhash6, self.METHOD, outhash5, unihash6) | ||
| 259 | self.assertEqual(result['unihash'], unihash5, 'Server failed to copy unihash from upstream') | ||
| 260 | |||
| 249 | def test_ro_server(self): | 261 | def test_ro_server(self): |
| 250 | (ro_client, ro_server) = self.start_server(dbpath=self.server.dbpath, read_only=True) | 262 | (ro_client, ro_server) = self.start_server(dbpath=self.server.dbpath, read_only=True) |
| 251 | 263 | ||
