mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
bitbake: hashserv: Implement read-only version of "report" RPC
When the hash equivalence server is in read-only mode, it should still return a unihash for a given "report" call if there is one. (Bitbake rev: d0bbb98553f5f3451606bd5f089b36cfe4219dc2) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
cfbb1d2cc0
commit
e31396eb1c
|
@ -124,6 +124,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
|||
self.max_chunk = bb.asyncrpc.DEFAULT_MAX_CHUNK
|
||||
self.backfill_queue = backfill_queue
|
||||
self.upstream = upstream
|
||||
self.read_only = read_only
|
||||
|
||||
self.handlers.update(
|
||||
{
|
||||
|
@ -131,13 +132,15 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
|||
"get-outhash": self.handle_get_outhash,
|
||||
"get-stream": self.handle_get_stream,
|
||||
"get-stats": self.handle_get_stats,
|
||||
# Not always read-only, but internally checks if the server is
|
||||
# read-only
|
||||
"report": self.handle_report,
|
||||
}
|
||||
)
|
||||
|
||||
if not read_only:
|
||||
self.handlers.update(
|
||||
{
|
||||
"report": self.handle_report,
|
||||
"report-equiv": self.handle_equivreport,
|
||||
"reset-stats": self.handle_reset_stats,
|
||||
"backfill-wait": self.handle_backfill_wait,
|
||||
|
@ -284,7 +287,27 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
|
|||
await self.socket.send("ok")
|
||||
return self.NO_RESPONSE
|
||||
|
||||
async def report_readonly(self, data):
|
||||
method = data["method"]
|
||||
outhash = data["outhash"]
|
||||
taskhash = data["taskhash"]
|
||||
|
||||
info = await self.get_outhash(method, outhash, taskhash)
|
||||
if info:
|
||||
unihash = info["unihash"]
|
||||
else:
|
||||
unihash = data["unihash"]
|
||||
|
||||
return {
|
||||
"taskhash": taskhash,
|
||||
"method": method,
|
||||
"unihash": unihash,
|
||||
}
|
||||
|
||||
async def handle_report(self, data):
|
||||
if self.read_only:
|
||||
return await self.report_readonly(data)
|
||||
|
||||
outhash_data = {
|
||||
"method": data["method"],
|
||||
"outhash": data["outhash"],
|
||||
|
|
|
@ -387,8 +387,8 @@ class HashEquivalenceCommonTests(object):
|
|||
outhash2 = '3c979c3db45c569f51ab7626a4651074be3a9d11a84b1db076f5b14f7d39db44'
|
||||
unihash2 = '90e9bc1d1f094c51824adca7f8ea79a048d68824'
|
||||
|
||||
with self.assertRaises(ConnectionError):
|
||||
ro_client.report_unihash(taskhash2, self.METHOD, outhash2, unihash2)
|
||||
result = ro_client.report_unihash(taskhash2, self.METHOD, outhash2, unihash2)
|
||||
self.assertEqual(result['unihash'], unihash2)
|
||||
|
||||
# Ensure that the database was not modified
|
||||
self.assertClientGetHash(rw_client, taskhash2, None)
|
||||
|
|
Loading…
Reference in New Issue
Block a user