Skip to content

Set a limit on firewall reports when the state of the firewall changes continuously#3574

Open
narrieta wants to merge 5 commits intoAzure:developfrom
narrieta:firewall
Open

Set a limit on firewall reports when the state of the firewall changes continuously#3574
narrieta wants to merge 5 commits intoAzure:developfrom
narrieta:firewall

Conversation

@narrieta
Copy link
Member

@narrieta narrieta commented Mar 6, 2026

If the state of the firewall flips too often from OK to incorrect and vice versa, we end up logging too many messages.

Added a limit of total messages per reporting period.


def test_it_should_log_the_state_of_the_firewall_once_per_reporting_period(self):
with MockIpTables() as mock_iptables:
EnableFirewall._REPORTING_PERIOD = datetime.timedelta(milliseconds=500)
Copy link
Member Author

Choose a reason for hiding this comment

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

Now EnableFirewall.init() references _REPORTING_PERIOD, so the latter needs to be initialized before instantiating EnableFirewall.

if (self._firewall_state == FirewallState.OK) != (firewall_state == FirewallState.OK):
# reset the report count if the firewall state goes from OK to not-OK or vice versa, but set an absolute limit per reporting period
if self._period_report_count <= 8:
self._report_count = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like if we enter this condition, we don't increment self._period_count and self._report_count before we call self._report() on lines 147, 150, 154, 162

Copy link
Member Author

@narrieta narrieta Mar 6, 2026

Choose a reason for hiding this comment

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

yes, the limit is per-report (1 iteration == 1 report), rather than per message, as it was 2 agent versions ago.

we check the limits at the top of the iteration (line 130) and then update them later, the updated values will take effect on the next iteration

i'll add this as a comment in the code

narrieta@microsoft added 2 commits March 6, 2026 14:35
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

Successfully merging this pull request may close these issues.

3 participants