Bug #16232
closedBug #11917: No compliance from a Rule with only one Directive (from a technique created in the editor) when the Directive is also applied in another Rule
Directive based on a multivalued technique are not marked overriden
Description
As explained in last comment of #11917, we broke something after the correction, and the correction disappeared. We should correct it back.
Updated by François ARMAND about 5 years ago
- Status changed from New to In progress
Updated by François ARMAND about 5 years ago
Actually, it's more complexe than expected. If the rule has 0 reports (which is likely if it has only one directive which is overrided), then we don't reach the point where we look for overrides. And so we don't even get a chance to see them:
// the method called to display rule compliance // class RuleCompliance (rule : Rule, rootRuleCategory: RuleCategory) { // ... def refreshCompliance() : JsCmd = { ( for { reports <- reportingService.findDirectiveRuleStatusReportsByRule(rule.id) allRules <- roRuleRepository.getAll() groups <- getGroups() updatedRule <- Box(allRules.find(_.id == rule.id)) directiveLib <- getFullDirectiveLib() allNodeInfos <- getAllNodeInfos() globalMode <- configService.rudder_global_policy_mode() } yield { val directiveData = ComplianceData.getRuleByDirectivesComplianceDetails(reports, updatedRule, allNodeInfos, directiveLib, groups, allRules, globalMode).json.toJsCmd ... // here "reports" is empty, so in getRuleByDirectivesComplianceDetails:
And:
def getRuleByDirectivesComplianceDetails ( report : RuleStatusReport , rule : Rule , ... ) : JsTableData[DirectiveComplianceLine] = { val overrides = getOverridenDirectiveDetails(report.overrides, directiveLib, allRules) // restrict mode calcul to node really targetted by that rule val appliedNodes = groupLib.getNodeIds(rule.targets, allNodeInfos) val nodeModes = appliedNodes.flatMap(id => allNodeInfos.get(id).map(_.policyMode)) val lines = getDirectivesComplianceDetails(report.report.directives.values.toSet, directiveLib, globalMode, ComputePolicyMode.directiveModeOnRule(nodeModes, globalMode)) // here, overrides will be empty because there's node report.
So to correct that bug, we will need a significative change were we start by collecting expected reports containing that rule (either in expected or in override).
It may be good to do that in all cases, because it would rely on correct data, not received/calculated one based on received.
Or perhaps we could do that only when we are in the case with 0 reports.
Updated by François ARMAND about 5 years ago
- Subject changed from Directive not written skipped even with 11917 correction to Directive based on a multivalued technique are not marked overriden
And it's totally not that.
The problem is actually that overrides are not correctly written for multivalued rules, so we don't get the "skipped" for directive based on "package" technique, but we will get it for directives based on "motd" technique. Updating title accordingly.
Updated by François ARMAND about 5 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from François ARMAND to Nicolas CHARLES
- Pull Request set to https://github.com/Normation/rudder/pull/2625
Updated by François ARMAND about 5 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder|a90b640b72a4bb5a99928d26775f637a433034a6.
Updated by Nicolas CHARLES about 5 years ago
- Fix check changed from To do to Error - Next version
Updated by François ARMAND about 5 years ago
- Fix check changed from Error - Next version to Error - Fixed
Updated by Vincent MEMBRÉ about 5 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 5.0.15 which was released today.