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 #23469: Reporting by node is not correct on directives and Rules #5050

Draft
wants to merge 1 commit into
base: branches/rudder/7.3
Choose a base branch
from

Conversation

VinceMacBuche
Copy link
Member

@VinceMacBuche VinceMacBuche commented Sep 21, 2023

https://issues.rudder.io/issues/23469

This pr is mostly replicating ComponentStatusReport behavior on other compliance view/types (mostly, applying blocks reporting logic)

I guess that we may have to refactor this and find out how to provide some abstraction over this. I have quite some idea but ...

It also simplifies a lot how the reports were regrouped by node, we were doing something really complicated but we just need to go deeper first (https://github.com/Normation/rudder/pull/5050/files#diff-c69298aa223fd7b6060cbed8a56d0472af28fd9ca9acdd466afc4f599ca56b8cL390 ) no more group by. Just explore at each level then regroup, almost again like we are doing for ComponentStatusReport ...

I also changed some "static" def, on several objects from def to val or lazy val. I think that may save us some computation time if we called them several times

subComponents.flatMap(_.withFilteredElement(predicate)) match {
case Nil => None
case l => Some(this.copy(subComponents = l))
}
}

def status: ReportType = {
val status: ReportType = {
Copy link
Member

Choose a reason for hiding this comment

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

I think we are oscillating between def and val because val (or lazy val) makes the number of allocation/memory consumption exploses. Did you look in history to see if we did the opposite change at some point?

Copy link
Member

Choose a reason for hiding this comment

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

It should at least be lazy val I believe (like other status field like in ComponentValueStatusReport, in all case not a val since it override a base field, it may lead to NPE)


def componentValues(v: String): List[ByRuleNodeCompliance] = componentValues.filter(_.values.exists(_.componentValue == v))

def status: ReportType
Copy link
Member

Choose a reason for hiding this comment

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

the meaning of status here is "the worst report type in sub component, based on target rules?"

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact i don't think it's used by component but i may be wrong, but for value it's is the worst in all cases. Probably in a block it should depends on reporting logic, But I'm not sure it is really used for a block
.

Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

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

Can you add a unit test that is failing before the change and green after ?

@fanf
Copy link
Member

fanf commented Oct 19, 2023

So, better understanding: it is not something that was wrong, more a missing feature.
I think it needs at least a second pass to:

  • change val into lazy val,
  • be more specific about what is necessary at each level, remove code duplication. There is several part where we have the same or almost the same logic copy/pasted, it will be extremelly hard to maintain
  • add unit tests to have non-regression tests on meaning going forward. These parts are horrible to track for subtile changes, we need assessment of these changes and have automatic alarms when we are changing behavior

@VinceMacBuche VinceMacBuche marked this pull request as draft January 25, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants