Skip to content
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

Fixes #19114: Overridden directives in the same rule are missing (not even "skipped") #3570

Conversation

fanf
Copy link
Member

@fanf fanf commented Apr 1, 2021

https://issues.rudder.io/issues/19114

So, the problem was that we were filtering the overriden directive globally, and not by rule, so we had only one overridden for all overrides.

So now, we filter rule by rule (in a smarter way, and at a place where we can do test, even better) and don't filter with the big axe when building the list of directive lines.

*/
def buildRuleStatusReport(ruleId: RuleId, nodeReports: Map[NodeId, NodeStatusReport]): RuleStatusReport = {
val toKeep = nodeReports.values.flatMap( _.reports ).filter(_.ruleId == ruleId).toList
// we don't keep overrides for a directive which is already in "toKeep" or that don't target that rule
val toKeepDir = toKeep.map(_.directives.keySet).toSet.flatten
val overrides = nodeReports.values.flatMap( _.overrides.filterNot(r => r.policy.ruleId != ruleId || toKeepDir.contains(r.policy.directiveId))).toList.distinct
RuleStatusReport(ruleId, toKeep, overrides)
// and we must make overrides unique - ie, we don't keep overridden that are overridden by directive themselve in the overridden list
Copy link
Member Author

Choose a reason for hiding this comment

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

yep, wasn't able to make it clearer :)

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit c364e72 into Normation:branches/rudder/6.2 Apr 1, 2021
@fanf fanf deleted the bug_19114/overridden_directives_in_the_same_rule_are_missing_not_even_skipped branch March 15, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants