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

Additive updates to services when discovery enabled #2318

Merged
merged 1 commit into from
Apr 29, 2020

Conversation

ashutosh-narkar
Copy link
Member

Earlier with discovery enabled, there was no protection against accidental
changes to the discovery service. This change prevents the discovery service
from being modified by checking it's config in the service bundle.

Fixes #2058

@ashutosh-narkar ashutosh-narkar changed the title Disco updates Additive updates to services when discovery enabled Apr 17, 2020
patrick-east
patrick-east previously approved these changes Apr 21, 2020
Copy link
Contributor

@patrick-east patrick-east left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

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

Looks pretty good. See comment about docs/error behaviour.

The discovery feature cannot be used to dynamically modify `labels` and `discovery`. This means that these configuration settings should be included
in the bootup configuration file provided to OPA. However, it can be used to modify `services` with the exception of the service used to download the discovery bundle.
Copy link
Member

Choose a reason for hiding this comment

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

Would be good to include a note here about why these settings cannot be modified and what happens if you try to. Something like:

In practice, discovery services do not change frequently. These configuration sections are treated as
immutable to avoid accidental configuration errors rendering OPA unable to discover new configuration.
If the discovered configuration changes the `discovery` or `labels` sections,
those changes are ignored. If the discovered configuration changes the discovery service,
an error will be logged.

This makes me wonder why we're erroring on disco service changes but not disco or label section changes.

// clients can be specified either as an array or as a map. Some systems (e.g.,
// Helm) do not have proper support for configuration values nested under
// arrays, so just support both here.
func ParseServicesConfig(raw json.RawMessage) (map[string]rest.Client, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Just a side note, but I imagine us having to change this API slightly in the future when we introduce support for other bundle download protocols like Git. In that case, the service will no longer be a rest.Client. No changes required at this time since this is just an internal API.

@tsandall
Copy link
Member

@ashutosh-narkar if you update the docs, we can merge this.

@ashutosh-narkar
Copy link
Member Author

Doc updated.

Earlier with discovery enabled, there was no protection against accidental
changes to the discovery service. This change prevents the discovery service
from being modified by checking it's config in the service bundle.

Fixes open-policy-agent#2058

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
@tsandall tsandall merged commit 5d2b9df into open-policy-agent:master Apr 29, 2020
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.

Add support for additive updates to the services configuration when discovery is enabled
3 participants