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

🧹 Make resolved policy execution use reporting queries #1496

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jaym
Copy link
Contributor

@jaym jaym commented Nov 25, 2024

The execution was previously implicitly tying together reporting queries and reporting jobs. This now uses the ReportingQueries section of the CollectorJob to do this.

Also, part of this change, I've introduced an additional reporting job types. One represents the executed query(reporting job by code id). The other represents a thing that is both a check and a query. This was helpful in fixing an issue where we don't properly forward a score and intead rescore it. This would turn skipped scores into unscored.

This last point is one of those non-backwards compatible changes. Once the new resolved policy is used everywhere, this bug will be seen in old clients. I don't see a way to fix it in a backwards compatible way, and its a small enough issue that I think its fine.

Note: While this should work with the old resolved policy, its probably best to wait to release it with the resolved policy rewrite.

Copy link
Contributor

github-actions bot commented Nov 25, 2024

Test Results

  1 files  ±0   26 suites  ±0   22s ⏱️ -1s
490 tests ±0  489 ✅ ±0  1 💤 ±0  0 ❌ ±0 
491 runs  ±0  490 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit 7ccf232. ± Comparison against base commit 42a2719.

♻️ This comment has been updated with latest results.

@@ -21,6 +21,7 @@ type query struct {
codeBundle *llx.CodeBundle
requiredProps map[string]string
resolvedProperties map[string]*llx.Primitive
notifies []string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this gets filled in with the information from the reporting queries section

n := ge.addReportingQueryNode(queryID, q)
if len(q.notifies) > 0 {
for _, notify := range q.notifies {
ge.addEdge(n.id, NodeID(notify))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

creates the edge from the node we use to represent a reporting query to the node we use to represent the reporting job. This will be the reporting job for query code id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also note that the reporting query node doesn't fully match whats in the resolved policy. We create one of these for every query, scoring or data. Only scoring queries are in the reporting queries section of the resolved policy.

var s *policy.Score
if v := nodeData.childScores[nodeData.queryID].score; v == nil {

if len(nodeData.childScores) == 0 {
s = &policy.Score{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed because reporting query nodes in our graph don't have children if they're data queries only.

Type: policy.ScoreType_Result,
}
} else {
s = proto.Clone(v).(*policy.Score)
Copy link
Member

Choose a reason for hiding this comment

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

not sure how often this gets called but we had some issues with memory/cpu consumption a while back. A lot of those were caused by proto.Clone. It is doing a lot of allocations and reflection magic which is super inefficient. If we need to clone this structure often, it's best to manually write a function that does that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can change this in a follow up pr. Would like to avoid it being part of this one

@jaym jaym force-pushed the jdm/ng-resolver-rqs branch 2 times, most recently from 07879d9 to b0da7d9 Compare November 27, 2024 15:02
The execution was previously implicitly tying together reporting queries
and reporting jobs. This now uses the ReportingQueries section of the
CollectorJob to do this.

Also, part of this change, I've introduced an additional reporting job
types. One represents the executed query(reporting job by code id). The
other represents a thing that is both a check and a query. This was
helpful in fixing an issue where we don't properly forward a score and
intead rescore it. This would turn skipped scores into unscored.

This last point is one of those non-backwards compatible changes. Once
the new resolved policy is used everywhere, this bug will be seen in old
clients. I don't see a way to fix it in a backwards compatible way, and
its a small enough issue that I think its fine.
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.

2 participants