Staging instance, all changes can be removed at any time

Skip to content

rpc_client: Allow http method declaration consistently with the rpc server

a7d1aa7b introduced that use for the server. Without doing this consistenly in the rpc client part, this won't work though.

The common usage we have is to define an interface in a swh module and make the rpc client and server code out of that interface. So those needs to be consistent.

Related to a7d1aa7b

Related to swh/meta$830 (as the current inconsistency, without the diff)

Test Plan

tox

Test with the vault everything is fine using docker

client code:

time doco exec swh-vault-worker /bin/bash

swh@51a13de681ec:/$ python3
Python 3.7.4 (default, Jul 13 2019, 14:04:11)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from swh.core.config import load_from_envvar
>>> from swh.model.hashutil import hash_to_bytes
>>> from swh.vault import get_vault
>>> config = load_from_envvar()
>>> vault = get_vault(**config['vault'])
>>> vault.task_info(obj_type="directory", obj_id=hash_to_bytes("838bc7ca7541fd96ed6e665c1485a0f8b6d4c3f3"))
{'id': 1, 'type': 'directory', 'object_id': b'\x83\x8b\xc7\xcauA\xfd\x96\xednf\\\x14\x85\xa0\xf8\xb6\xd4\xc3\xf3', 'task_id': None, 'task_status': 'new', 'sticky': False, 'ts_created': datetime.datetime(2020, 10, 23, 10, 1, 21, 384052, tzinfo=datetime.timezone(datetime.timedelta(0), '+00:00')), 'ts_done': None, 'ts_last_access': datetime.datetime(2020, 10, 23, 10, 1, 21, 384052, tzinfo=datetime.timezone(datetime.timedelta(0), '+00:00')), 'progress_msg': None}
>>> vault.cook_request(obj_type="directory", obj_id=hash_to_bytes("838bc7ca7541fd96ed6e665c1485a0f8b6d4c3f3"))
{'id': 1, 'type': 'directory', 'object_id': b'\x83\x8b\xc7\xcauA\xfd\x96\xednf\\\x14\x85\xa0\xf8\xb6\xd4\xc3\xf3', 'task_id': None, 'task_status': 'new', 'sticky': False, 'ts_created': datetime.datetime(2020, 10, 23, 10, 1, 21, 384052, tzinfo=datetime.timezone(datetime.timedelta(0), '+00:00')), 'ts_done': None, 'ts_last_access': datetime.datetime(2020, 10, 23, 10, 1, 21, 384052, tzinfo=datetime.timezone(datetime.timedelta(0), '+00:00')), 'progress_msg': None}
...

server code:

$ doco logs -f swh-vault
...
swh-vault_1                     | INFO:aiohttp.access:192.168.176.30 [23/Oct/2020:10:04:30 +0000] "GET /fetch HTTP/1.1" 400 1132 "-" "python-requests/2.24.0"
swh-vault_1                     | [INFO] aiohttp.access -- 192.168.176.30 [23/Oct/2020:10:04:30 +0000] "GET /fetch HTTP/1.1" 400 1132 "-" "python-requests/2.24.0"
swh-vault_1                     | INFO:aiohttp.access:192.168.176.30 [23/Oct/2020:10:12:55 +0000] "GET /progress HTTP/1.1" 200 394 "-" "python-requests/2.24.0"
swh-vault_1                     | [INFO] aiohttp.access -- 192.168.176.30 [23/Oct/2020:10:12:55 +0000] "GET /progress HTTP/1.1" 200 394 "-" "python-requests/2.24.0"
swh-vault_1                     | INFO:aiohttp.access:192.168.176.30 [23/Oct/2020:10:12:55 +0000] "POST /cook HTTP/1.1" 200 394 "-" "python-requests/2.24.0"
swh-vault_1                     | [INFO] aiohttp.access -- 192.168.176.30 [23/Oct/2020:10:12:55 +0000] "POST /cook HTTP/1.1" 200 394 "-" "python-requests/2.24.0"
...

Migrated from D4341 (view on Phabricator)

Merge request reports

Loading