ansible/event-driven-ansible

file_watch raises QueueFull exception on event trigger

rcarrillocruz opened this issue · 0 comments

I have the following rulebook:

- name: Local Test Runner Rules
  hosts: all
  sources:
    - name: file_watch
      ansible.eda.file_watch:
        path: "/home/cloud-user/folder-to-watch"
        recursive: true
  rules:
    - name: run tests 1
      condition: event.type == "DirModifiedEvent"
      action:
        debug:

Then, I run it with rulebook with:

[cloud-user@ricky-aap-containerized-installer eda]$ ansible-rulebook -i inventory.yml --rulebook rulebook.yml --verbose
2023-05-22 15:57:29,369 - ansible_rulebook.app - INFO - Starting sources
2023-05-22 15:57:29,369 - ansible_rulebook.app - INFO - Starting rules
2023-05-22 15:57:29,369 - ansible_rulebook.engine - INFO - run_ruleset
2023-05-22 15:57:29,370 - drools.ruleset - INFO - Using jar: /home/cloud-user/.local/lib/python3.9/site-packages/drools/jars/drools-ansible-rulebook-integration-runtime-1.0.1-SNAPSHOT.jar
2023-05-22 15:57:29 987 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.AbstractRulesEvaluator - Start automatic pseudo clock with a tick every 100 milliseconds
2023-05-22 15:57:29,991 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Local Test Runner Rules", "hosts": ["all"], "sources": [{"EventSource": {"name": "file_watch", "source_name": "ansible.eda.file_watch", "source_args": {"path": "/home/cloud-user/folder-to-watch", "recursive": true}, "source_filters": []}}], "rules": [{"Rule": {"name": "run tests 1", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "type"}, "rhs": {"String": "DirModifiedEvent"}}}]}, "actions": [{"Action": {"action": "debug", "action_args": {}}}], "enabled": true}}]}
2023-05-22 15:57:30,003 - ansible_rulebook.engine - INFO - load source
2023-05-22 15:57:30,615 - ansible_rulebook.engine - INFO - load source filters
2023-05-22 15:57:30,615 - ansible_rulebook.engine - INFO - loading eda.builtin.insert_meta_info
2023-05-22 15:57:31,187 - ansible_rulebook.engine - INFO - Calling main in ansible.eda.file_watch
2023-05-22 15:57:31,190 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
2023-05-22 15:57:31 190 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected
2023-05-22 15:57:31,191 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Local Test Runner Rules
2023-05-22 15:57:31,192 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Local Test Runner Rules

If I run 'touch lol' at /home/cloud-user/folder-to-watch, then rulebook raises exception:

2023-05-22 15:58:16,677 - asyncio - ERROR - Exception in callback FilteredQueue.put_nowait({'change': 'modified', 'meta': {'received_at': '2023-05-22T19:58:16.677597Z', 'source': {'name': 'file_watch', 'type': 'ansible.eda.file_watch'}, 'uuid': '086c6ff7-4d6...-4c36eebafde3'}, 'root_path': '/home/cloud-...lder-to-watch', 'src_path': '/home/cloud-...lder-to-watch', ...})
handle: <Handle FilteredQueue.put_nowait({'change': 'modified', 'meta': {'received_at': '2023-05-22T19:58:16.677597Z', 'source': {'name': 'file_watch', 'type': 'ansible.eda.file_watch'}, 'uuid': '086c6ff7-4d6...-4c36eebafde3'}, 'root_path': '/home/cloud-...lder-to-watch', 'src_path': '/home/cloud-...lder-to-watch', ...})>
Traceback (most recent call last):
  File "/usr/lib64/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/cloud-user/.local/lib/python3.9/site-packages/ansible_rulebook/engine.py", line 82, in put_nowait
    self.queue.put_nowait(data)
  File "/usr/lib64/python3.9/asyncio/queues.py", line 151, in put_nowait
    raise QueueFull
asyncio.queues.QueueFull