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 #22150: API for directive compliance #4606

Conversation

ElaadF
Copy link
Member

@ElaadF ElaadF commented Dec 12, 2022

@ElaadF ElaadF added the WIP Use that label for a Work In Progress PR that must not be merged yet label Dec 12, 2022
~ ("compliance" -> directive.compliance.complianceWithoutPending(precision))
~ ("mode" -> directive.mode.name)
~ ("complianceDetails" -> percents(directive.compliance, precision))
~ ("rules" -> rules(directive.rules, level, precision))
Copy link
Member Author

Choose a reason for hiding this comment

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

I struggle to get the rules that contain nodes and nodes that contain rules. It seems like it's always rules -> directives -> nodes

@ElaadF
Copy link
Member Author

ElaadF commented Dec 16, 2022

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 7a13e1f to b0b58aa Compare December 16, 2022 09:41
~ ("mode" -> directive.mode.name)
~ ("complianceDetails" -> percents(directive.compliance, precision))
// ~ ("rules" -> rules(directive.rules.map(_.), level, precision))
~ ("nodes" -> byNodes(directive.nodes, level, precision))
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to get a structure like

"nodes": [
          {
            "id": "831b9c93-bb96-4d48-8c4e-91ca19b98bde",
            "name": "prod-zabbix-01.lab.rudder.io",
            "compliance": 100.0,
            "complianceDetails": {
              "auditCompliant": 100.0
            },
            "rules": [
              {
                "id": "94e9b2ed-6f5a-44a2-a8c5-82b88f4d85b7",
                "name": "Training - Trigger Command",
                "compliance": 100.0,
                "complianceDetails": {
                  "auditCompliant": 100.0
                },
                "components": [
                  {
                    "name": "Copy script agent-hello onto Nodes ",
                    "compliance": 100.0,
                    "complianceDetails": {
                      "auditCompliant": 100.0
                    },
                    "values": [
                      {
                        "value": "/opt/rudder/share/commands/agent-hello",
                        "reports": [
                          {
                            "status": "auditCompliant",
                            "message": "Copying /opt/rudder/share/commands/agent-hello from agent-hello was correct"
                          }
                        ]
                      }
                    ]
                  }
                ]

Copy link
Member

Choose a reason for hiding this comment

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

why do you have a rule and not a directive?

Copy link
Member

Choose a reason for hiding this comment

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

directive is at top level. we want compliance for a directive

@ElaadF
Copy link
Member Author

ElaadF commented Dec 30, 2022

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from b0b58aa to 4bc69b7 Compare December 30, 2022 08:02
directive.map(_.id.uid.value).getOrElse("Unknown"),
ComplianceLevel.sum(byRules.map(_.compliance)),
compliance.mode,
byRules,
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we expect Seq[ByDirectiveByRuleComponentCompliance] but getByRulesCompliance return Seq[ByRuleRuleCompliance]

@ElaadF
Copy link
Member Author

ElaadF commented Dec 30, 2022

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 4bc69b7 to 83e328a Compare December 30, 2022 14:53
@ElaadF
Copy link
Member Author

ElaadF commented Jan 6, 2023

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 83e328a to 07b61de Compare January 6, 2023 07:52
@ElaadF
Copy link
Member Author

ElaadF commented Jan 6, 2023

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 07b61de to 2d75e0a Compare January 6, 2023 07:59
@ElaadF
Copy link
Member Author

ElaadF commented Jan 6, 2023

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 2d75e0a to 0de5f23 Compare January 6, 2023 08:05
@ElaadF
Copy link
Member Author

ElaadF commented Jan 6, 2023

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from 0de5f23 to b325de9 Compare January 6, 2023 08:56
@ElaadF ElaadF removed the WIP Use that label for a Work In Progress PR that must not be merged yet label Jan 6, 2023
@ElaadF
Copy link
Member Author

ElaadF commented Jan 9, 2023

Commit modified

@ElaadF ElaadF force-pushed the ust_22150/api_for_directive_compliance branch from b325de9 to b3a987c Compare January 9, 2023 10:06
@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 98490c5 into Normation:master Jan 9, 2023
@@ -160,6 +160,13 @@ object ComplianceApi extends ApiModuleProvider[ComplianceApi] {
val dataContainer = Some("globalCompliance")
}

final case object GetDirectiveComplianceId extends ComplianceApi with OneParam with StartsAtVersion10 with SortIndex {
Copy link
Member

Choose a reason for hiding this comment

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

why does it start at version 10 and not latest version ?

_ = TimingDebugLogger.trace(s"API GetDirectiveId - getting directive compliance in ${t3 - t2} ms")

} yield {
if (version.value <= 6) {
Copy link
Member

Choose a reason for hiding this comment

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

it starts only in rudder 7.3, so there's no way the version 6 of API is possible

This pull request was closed.
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.

4 participants