Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for fatal ledger errors on dispatch task completion #659

Merged
merged 4 commits into from Aug 14, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions aries_cloudagent/core/conductor.py
Expand Up @@ -274,6 +274,13 @@ def dispatch_complete(self, message: InboundMessage, completed: CompletedTask):
LOGGER.exception(
"Exception in message handler:", exc_info=completed.exc_info
)
if isinstance(completed.exc_info[1], LedgerConfigError) or isinstance(
completed.exc_info[1], LedgerTransactionError
):
LOGGER.error("Shutdown with %s", str(completed.exc_info[1]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could cover with unit test in test_conductor.py:

    async def test_dispatch_complete_fatal_x(self):
        builder: ContextBuilder = StubContextBuilder(self.test_settings)
        conductor = test_module.Conductor(builder)

        message_body = "{}"
        receipt = MessageReceipt(direct_response_mode="snail mail")
        message = InboundMessage(message_body, receipt)
        mock_task = async_mock.MagicMock(
            exc_info=(test_module.LedgerTransactionError, ("Ledger is wobbly"), "..."),
            ident="abc",
            timing={
                "queued": 1234567890,
                "unqueued": 1234567899,
                "started": 1234567901,
                "ended": 1234567999,
            },
        )

        await conductor.setup()
        conductor.dispatch_complete(message, mock_task)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test added, thanks @sklump !

self.admin_server.notify_fatal_error()
else:
LOGGER.error("DON'T Shutdown with %s", str(completed.exc_info[1]))
self.inbound_transport_manager.dispatch_complete(message, completed)

async def get_stats(self) -> dict:
Expand Down