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

file_watch raises QueueFull exception on event trigger #130

Open
rcarrillocruz opened this issue May 22, 2023 · 1 comment
Open

file_watch raises QueueFull exception on event trigger #130

rcarrillocruz opened this issue May 22, 2023 · 1 comment

Comments

@rcarrillocruz
Copy link
Contributor

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
@zchef2k
Copy link

zchef2k commented Sep 14, 2024

I came here for the same error but for a slightly different reason. I realize this is an old issue and you may have moved on, but try setting your condition to one of created|deleted|modified|moved per event source code.

My action will fire on a condition match and I get an almost identical traceback whenever a file operation in the directory I'm watching doesn't match the condition. Is this expected? It doesn't crash the rulebook but it seems like it should handle this more gracefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants