-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
sdk: fix bug while activating the bundle plugin #6689
sdk: fix bug while activating the bundle plugin #6689
Conversation
✅ Deploy Preview for openpolicyagent ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
For some reason the bundle plugin activation with multiple optimized bundles, builded in v1 syntax, results in parsing error. During the activation of the bundle, when we need to parse the rego modules, the ParserOptions is not forwarded to the `bundle.ActivateOps`, so the v1 syntax does not seem to be properly parsed. Signed-off-by: Francisco Rodrigues <ednofco@gmail.com>
c499d9a
to
7dd1dd8
Compare
…he function of multiple consecutive bundle updates. Signed-off-by: Johan Fylling <johan.dev@fylling.se>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdk/opa_test.go
Outdated
@@ -2844,3 +2844,54 @@ func toMetricMap(metrics []*promdto.MetricFamily) map[string]bool { | |||
} | |||
return metricMap | |||
} | |||
|
|||
func TestActivateOptimizedV1Bundles(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rename this to TestActivateV1Bundles
.
Colloquially, an "optimized" bundle is one that has been constructed through an optimized OPA build (e.g. opa build
is used with the -O
flag).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanfylling I've renamed the test and simplified the test structure to better reflect this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
Compiler: compiler, | ||
Metrics: p.status[name].Metrics, | ||
Bundles: map[string]*bundle.Bundle{name: b}, | ||
ParserOptions: p.manager.ParserOptions(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find 👍 🎉 .
Conflicts: plugins/bundle/plugin_test.go
ed3dc24
to
dad69b8
Compare
The bug in activating bundles in the SDK is not necessarily related to optimized bundles, but specifically for v1 bundles. So the test was renamed to `TestActivateV1Bundles` and the test structure simplified to better describe the scenario. Signed-off-by: Francisco Rodrigues <ednofco@gmail.com>
dad69b8
to
2d4a6ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Thank you for your contribution! 😃
…policy-agent#6689) Fixing issue where active parser options aren't propagated to module reload during bundle activation. Signed-off-by: Francisco Rodrigues <ednofco@gmail.com> Signed-off-by: Thomas Sidebottom <thomas.sidebottom@va.gov>
For some reason the bundle plugin activation with multiple optimized bundles, builded in v1 syntax, results in parsing error.
During the activation of the bundle, when we need to parse the rego modules, the ParserOptions is not forwarded to the
bundle.ActivateOps
, so the v1 syntax does not seem to be properly parsed.Why the changes in this PR are needed?
The OPA SDK does not initialize when provided multiple bundles that were optimized with v1 syntax.
What are the changes in this PR?
Basically, I just forward the ParserOptions from the plugin manager to the
bundle.ActivateOpts
struct.Notes to assist PR review:
I am not totally sure about what the root problem is, but I was able to provide a failing test
and the fix.
It might be related to the issue #6450
Further comments: