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

add EvaluationMeta empty interface to each Result #263

Merged
merged 7 commits into from
Dec 7, 2022

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Nov 9, 2022

what

This patch adds an empty interface to keep evaluation metadata about a given Result.

why

By collecting these measurements, we can expose them to consumers, like gatekeeper to use for reporting or logging.

reviewer notes:

Signed-off-by: Alex Pana 8968914+acpana@users.noreply.github.com

@acpana acpana marked this pull request as ready for review November 10, 2022 00:13
@acpana
Copy link
Contributor Author

acpana commented Nov 10, 2022

@maxsmythe let me know what you think of the open questions above! 🙏🏼

@@ -588,6 +595,13 @@ func (c *Client) review(ctx context.Context, target string, constraints []*unstr
Trace: trace,
Target: target,
Results: results,
ResponseMeta: &types.ResponseMeta{
Copy link
Contributor

Choose a reason for hiding this comment

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

The intended use case for this feature would be: if I have 5 constraint templates and one of them is slow, I would like to identify which template is the culprit.

In order to do that, I'd need to be able to associate a given constraint template with its total runtime.

TL;DR we need to break down these Meta objects by constraint template name... probably by modifying the engine interface to allow that.

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana changed the title add ResponseMeta add ResultMeta to each Result Nov 17, 2022
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana
Copy link
Contributor Author

acpana commented Nov 23, 2022

hey @maxsmythe thanks for the guidance here.

Starting with 8057241, we have an interface exposing an EngineStatsString ; lmk what you think please 🙏🏼

constraint/pkg/client/drivers/local/driver.go Outdated Show resolved Hide resolved
constraint/pkg/client/drivers/local/driver.go Outdated Show resolved Hide resolved
constraint/pkg/client/drivers/local/driver.go Outdated Show resolved Hide resolved
constraint/pkg/types/validation.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana acpana changed the title add ResultMeta to each Result add EvaluationMeta empty interface to each Result Nov 30, 2022
Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM with one question around whether we want to bake units into the field name for clarity. Thanks for this!

// RegoEvaluationMeta has rego specific metadata from evaluation.
type RegoEvaluationMeta struct {
// TemplateRunTime is the number of milliseconds it took to evaluate all constraints for a template.
TemplateRunTime float64 `json:"templateRunTime"`
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add the units to this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could we avoid that given that the godoc for the field calls out the units?

Copy link
Contributor

Choose a reason for hiding this comment

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

Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
@acpana
Copy link
Contributor Author

acpana commented Dec 1, 2022

AFAIU, the gatekeeper test wf here will fail since EvaluationMeta won't be present. Is that ok to ignore (barring no other failures) in order to merge and then update the gatekeeper tests?

Here's an old gatekeeper test run: https://github.com/open-policy-agent/frameworks/actions/runs/3586143965/jobs/6037544599 (it seems mostly gator test related changes needed)

@maxsmythe
Copy link
Contributor

This shouldn't be a breaking change, I'd expect Gatekeeper Test to pass, that being said, that test is informational

@maxsmythe
Copy link
Contributor

Looking at the failure you linked, it seems like some of G8r's tests are written in a brittle fashion, such that the addition of a new field causes them to break.

These are benign, though it does mean updating the dependency will take some work.

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

3 participants