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

OPA: Fail fast on discovery or bundle download errors #3120

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mjungsbluth
Copy link
Collaborator

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.

@@ -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)
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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...

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

2 participants