Skip to content

Conversation

@Duologic
Copy link
Contributor

@Duologic Duologic commented May 7, 2025

The use of std.prune(std.map()) is slow and uses a big stack, on big
rulesets this can cause a 'RUNTIME ERROR: max stack frames exceeded.'.

It is better to use std.filter() to remove an element from an array.

@Duologic Duologic requested a review from pstibrany May 7, 2025 12:26
@Duologic Duologic force-pushed the duologic/mixin-utils-noprune branch 2 times, most recently from ed91c53 to a44d28f Compare May 7, 2025 12:32
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Changes lgtm. (Could it be possible to have some tests? Don't block this PR on it though.)

Duologic added 3 commits May 7, 2025 14:33
The use of `std.prune(std.map())` is slow and uses a big stack, on big
rulesets this can cause a 'RUNTIME ERROR: max stack frames exceeded.'.

It is better to use `std.filter()` to remove an element from an array.
@Duologic Duologic force-pushed the duologic/mixin-utils-noprune branch from c5f4fc4 to ee07910 Compare May 7, 2025 12:34

removeAlertRuleGroup(ruleName):: {
prometheusAlerts+:: $.removeRuleGroup(ruleName),
prometheusAlerts+: $.removeRuleGroup(ruleName),
Copy link
Contributor Author

@Duologic Duologic May 7, 2025

Choose a reason for hiding this comment

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

+: means keep visiblity as it was, so if the field was hidden upstream, then it will stay hidden. I opted for this change to avoid making the test cases more complicated.

+ test.case.new(
'removeAlertRuleGroup',
test.expect.eq(
actual=config + utils.removeAlertRuleGroup('group1'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding tests. This also shows how these functions are supposed to be used! That's very useful!

)

+ test.case.new(
'removeAlerts',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran all but this test case against main. This test case represents a new feature, removeAlerts now accepts an array.

@Duologic Duologic merged commit 254dfb6 into master May 7, 2025
10 checks passed
@Duologic Duologic deleted the duologic/mixin-utils-noprune branch May 7, 2025 17:01
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.

2 participants