From 2665c5a4a89c0838ecc0cf566d06e16befc573d0 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Mon, 12 Aug 2024 13:49:14 -0400 Subject: [PATCH] fix: dont send session stats after every action when audit skipped (#704) https://issues.redhat.com/browse/AAP-28915 When doing performance testing the session stats after every action causes the DB to be updated. If we are skipping audit events we can send the session stats at the regular heartbeat interval and when the rulebook ends. --- ansible_rulebook/rule_set_runner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ansible_rulebook/rule_set_runner.py b/ansible_rulebook/rule_set_runner.py index bf1825db..211da3e6 100644 --- a/ansible_rulebook/rule_set_runner.py +++ b/ansible_rulebook/rule_set_runner.py @@ -291,7 +291,11 @@ async def _drain_actionplan_queue(self): queue_item = await self.ruleset_queue_plan.plan.queue.get() rule_run_at = run_at() action_item = cast(ActionContext, queue_item) - if self.parsed_args and self.parsed_args.heartbeat > 0: + if ( + self.parsed_args + and self.parsed_args.heartbeat > 0 + and not settings.skip_audit_events + ): await send_session_stats( self.event_log, session_stats(self.ruleset_queue_plan.ruleset.name),