Set a limit on firewall reports when the state of the firewall changes continuously#3574
Open
narrieta wants to merge 5 commits intoAzure:developfrom
Open
Set a limit on firewall reports when the state of the firewall changes continuously#3574narrieta wants to merge 5 commits intoAzure:developfrom
narrieta wants to merge 5 commits intoAzure:developfrom
Conversation
added 2 commits
March 5, 2026 16:25
narrieta
commented
Mar 6, 2026
|
|
||
| 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) |
Member
Author
There was a problem hiding this comment.
Now EnableFirewall.init() references _REPORTING_PERIOD, so the latter needs to be initialized before instantiating EnableFirewall.
maddieford
reviewed
Mar 6, 2026
| 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 |
Contributor
There was a problem hiding this comment.
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
Member
Author
There was a problem hiding this comment.
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
nagworld9
reviewed
Mar 6, 2026
added 2 commits
March 6, 2026 14:35
maddieford
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.