Skip to content

RPC retry entrypoints can't retry other RPC retry entrypoints #29

@gchai87

Description

@gchai87

Describe the bug
Retrying rpc endpoint with decorator imported from nameko-amqp-retry will not work if it then makes a call to another rpc endpoint with decorator imported from nameko-amqp-retry.

To Reproduce
setting up 2 services both with nameko_amqp_retry rpc entrypoints

service1

import logging

from nameko.rpc import RpcProxy
from nameko_amqp_retry import entrypoint_retry
from nameko_amqp_retry.rpc import rpc

logger = logging.getLogger(name)

class Service1():

name = "service1"

service2_rpc = RpcProxy("service2")

@rpc
@entrypoint_retry(retry_for=KeyError, limit=2, schedule=[1000])
def call_service2(self):
    logger.info(self.service2_rpc.do_bad_thing())
    a = {"bad": "thing"}
    return a["good"]

service2

import logging

from nameko_amqp_retry.rpc import rpc

logger = logging.getLogger(name)

class Service2():

name = "service2"

@rpc
def do_bad_thing(self):
    return "Works the first time only."

Call service 2 with service1
n.rpc.service1.call_service2()

results in KeyError as expected first but on retry it hits a MethodNotFound error instead of second KeyError:

nameko run --config deploy/core/config.yaml service1.services.core.service:Service1
2019-03-28 16:42:15,484 [INFO] [studapart-service] [nameko.runners] starting services: service1
2019-03-28 16:42:15,545 [INFO] [studapart-service] [kombu.mixins] Connected to amqp://guest:**@127.0.0.1:5672//
2019-03-28 16:42:16,349 [INFO] [studapart-service] [service1.services.core.service] Works the first time only.
2019-03-28 16:42:16,349 [WARNING] [studapart-service] [nameko.containers] (expected) error handling worker <WorkerContext [service1.call_service2] at 0x1117c1b70>: Backoff(uninitialised)
Traceback (most recent call last):
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko_amqp_retry/decorators.py", line 64, in wrapper
return wrapped(*args, **kwargs)
File "/Users/gchai/project/service1/src/service1/services/core/service.py", line 21, in call_service2
return a["good"]
KeyError: 'good'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko/containers.py", line 392, in _run_worker
result = method(*worker_ctx.args, **worker_ctx.kwargs)
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko_amqp_retry/decorators.py", line 66, in wrapper
six.raise_from(backoff_cls(), exc)
File "", line 3, in raise_from
nameko_amqp_retry.decorators.backoff_factory..CustomBackoff: Backoff(uninitialised)
2019-03-28 16:42:17,288 [ERROR] [studapart-service] [nameko.containers] error handling worker <WorkerContext [service1.call_service2] at 0x111807710>: call_service2
Traceback (most recent call last):
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko/containers.py", line 392, in _run_worker
result = method(*worker_ctx.args, **worker_ctx.kwargs)
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko_amqp_retry/decorators.py", line 64, in wrapper
return wrapped(*args, **kwargs)
File "/Users/gchai/project/service1/src/service1/services/core/service.py", line 19, in call_service2
logger.info(self.service2_rpc.do_bad_thing())
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko/rpc.py", line 373, in call
return reply.result()
File "/Users/gchai/.virtualenvs/svc1/lib/python3.6/site-packages/nameko/rpc.py", line 331, in result
raise deserialize(error)
nameko.exceptions.MethodNotFound: call_service2

Expected behavior
Not hitting MethodNotFound exceptions. Example above should retry KeyError twice and give up.

Environment (please complete the following information):

  • Nameko version: 2.12.0
  • Nameko-amqp-retry version: 0.7.1
  • Python version: 3.6
  • OS: MacOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions