-
Notifications
You must be signed in to change notification settings - Fork 177
fix(mixin-utils): remove std.prune and use std.filter instead #1441
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
Conversation
ed91c53 to
a44d28f
Compare
pstibrany
left a comment
There was a problem hiding this 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.)
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.
c5f4fc4 to
ee07910
Compare
|
|
||
| removeAlertRuleGroup(ruleName):: { | ||
| prometheusAlerts+:: $.removeRuleGroup(ruleName), | ||
| prometheusAlerts+: $.removeRuleGroup(ruleName), |
There was a problem hiding this comment.
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'), |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
The use of
std.prune(std.map())is slow and uses a big stack, on bigrulesets this can cause a 'RUNTIME ERROR: max stack frames exceeded.'.
It is better to use
std.filter()to remove an element from an array.