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

Allow configuration of bundle download behaviour of open-policy-agent filter #3464

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

torwunder
Copy link

Addresses: #3119

Solution
add option to override the period trigger for discovery and bundle plugins

  • control timing of f.ex. bundle download directly (also adding jitter to avoid different opa instances updating at the same time)
  • fail fast for non-recoverable errors

Context
The current (and future default) behaviour is relying on the configurable startup timeout to determine if the open-policy-agent filter can successfully serve requests (if it was able to download the bundles, aso).
The solution is based on a [change](add option to override period trigger for plugin) in upstream opa that exposes the httpError struct on the trigger method.

@mjungsbluth mjungsbluth added the minor no risk changes, for example new filters label Mar 31, 2025
@torwunder torwunder force-pushed the override-period-plugin-triggers branch from fb17e73 to d2b81c0 Compare March 31, 2025 13:05

func (opa *OpenPolicyAgentInstance) verifyAllPluginsStarted() error {
allPluginsReady := true
for pluginName, status := range opa.manager.PluginStatus() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we make it explicit that we only wait for the bundle and discovery plugin?

Copy link
Author

Choose a reason for hiding this comment

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

it is checking the status of all plugins to align with the normal startup without the control loop

@torwunder torwunder force-pushed the override-period-plugin-triggers branch from d2b81c0 to a38dc7f Compare April 1, 2025 07:49
Copy link
Member

@AlexanderYastrebov AlexanderYastrebov left a comment

Choose a reason for hiding this comment

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

I did a first pass

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds configuration options to control the periodic triggering behavior of the Open Policy Agent filter, allowing manual override of the automatic bundle downloads and discovery triggers. Key changes include:

  • Adding new configuration flags and options for override behavior, plugin trigger interval, and maximum trigger jitter.
  • Updating the startup and plugin trigger logic in both production and test code.
  • Introducing configuration hook changes for manual override in plugin triggers.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
skipper.go Adds new options for enabling override of period triggers and configuring intervals/jitter.
filters/openpolicyagent/openpolicyagent_test.go Updates tests to cover various scenarios for plugin trigger override and error handling.
filters/openpolicyagent/openpolicyagent.go Implements manual override handling for plugin triggers and adds retry logic.
filters/openpolicyagent/internal/confighook.go and confighook_test.go Introduces a manual override hook for discovery and bundle plugin configurations.
config/config.go and config/config_test.go Updates configuration schema and tests with new flags related to plugin trigger override.

@AlexanderYastrebov
Copy link
Member

AlexanderYastrebov commented Apr 1, 2025

@torwunder FYI, I am testing what Copilot review is capable of so I've requested a review from it.

@torwunder torwunder force-pushed the override-period-plugin-triggers branch from a38dc7f to 47fbff0 Compare April 2, 2025 06:50
- control timing of f.ex. bundle download directly
- fail fast for non-recoverable errors

Signed-off-by: Torsten Wunderlich <[email protected]>
@torwunder torwunder force-pushed the override-period-plugin-triggers branch from 47fbff0 to ebd3bea Compare April 2, 2025 15:32
config/config.go Outdated
OpenPolicyAgentMaxRequestBodySize int64 `yaml:"open-policy-agent-max-request-body-size"`
OpenPolicyAgentMaxMemoryBodyParsing int64 `yaml:"open-policy-agent-max-memory-body-parsing"`
EnableOpenPolicyAgent bool `yaml:"enable-open-policy-agent"`
EnableOpenPolicyAgentOverridePeriodTriggers bool `yaml:"enable-open-policy-agent-override-period-triggers"`
Copy link
Member

Choose a reason for hiding this comment

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

Should it have -plugin in the name?
Also please put related configs next to each other:

enable-open-policy-agent[-plugin]-override-period-triggers
open-policy-agent-plugin-trigger-interval

Copy link
Author

Choose a reason for hiding this comment

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

part of #3464 (comment)

@torwunder torwunder force-pushed the override-period-plugin-triggers branch from bce1f8a to 5aa86e1 Compare April 9, 2025 12:13
@torwunder torwunder force-pushed the override-period-plugin-triggers branch from 5aa86e1 to 8be65b3 Compare April 9, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor no risk changes, for example new filters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants