-
Notifications
You must be signed in to change notification settings - Fork 345
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
OPA: Fail fast on discovery or bundle download errors #3120
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Magnus Jungsbluth <[email protected]>
@@ -476,25 +477,71 @@ func (registry *OpenPolicyAgentRegistry) new(store storage.Store, configBytes [] | |||
// Start asynchronously starts the policy engine's plugins that download | |||
// policies, report status, etc. | |||
func (opa *OpenPolicyAgentInstance) Start(ctx context.Context, timeout time.Duration) error { | |||
err := opa.manager.Start(ctx) | |||
discoveryPlugin := discovery.Lookup(opa.manager) | |||
bundlePlugin := bundle.Lookup(opa.manager) |
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.
I guess this needs to happen later when the discovery plugin is actually ready
|
||
discoveryPlugin.RegisterListener("startuplistener", func(status bundle.Status) { | ||
if len(status.Errors) > 0 { | ||
select { |
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.
I don't think the select is needed here (I wouldn't know what it even does in this case), sending to a channel can be done without it.
err = waitFunc(ctx, pluginsReady, 100*time.Millisecond) | ||
// Add listener for bundle plugin on discovery plugin OK, because bundlePlugin is dependent on the configuration | ||
// discovered using the discovery configs | ||
bundlePlugin.Register("startuplistener", func(status bundle.Status) { |
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.
Given the comment above, the check on status seems to be missing...
73bdf5a
to
583fc58
Compare
As part of #3119, this PR changes the behaviour on starting up OPA instances inside the OPA based Skipper filters.
Currently even in the face of download errors of bundles, the default timeout of 30s is applied.
By using listeners both for bundle download and discovery bundle download, we can detect a failure early despite the respective plugins still waiting for the bundles to become available.
Still a draft because tests are missing, there are some cleanups in the code that need to be done.