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

Block options and not prefixes in Kafka Connector configs #10503

Conversation

scholzj
Copy link
Member

@scholzj scholzj commented Aug 27, 2024

Type of change

  • Bugfix

Description

Currently, we use forbidden prefixes to block users from setting various configurations managed directly by the Strimzi Cluster Operator. When a user configures any option starting with the prefix (apart from the defined exceptions), the option will be ignored and removed from the config. This worked fine so far for most operands which have mostly a static set of configuration options.

But it does not work well for Kafka Connectors. In Kafka Connectors, we block three options: name, connector.class, and tasks.max. These are all important options to block as they would cause errors if they were set by users (especially the name option). But in Kafka Connectors, each connector has different configuration options. And therefore the likelihood of a conflict when blocking the whole prefix is not impossible, especially with a generic option such as name. #10500 describes one such conflict.

This PR improves how we handle the forbidden prefixes. It keeps the original logic, but it also adds support for forbidden options to the AbstractConfiguration. That allows us to keep the existing logic where it suits (for example blocking whole range of security-related options). But it allows to also block individual options such as those in Kafka Connectors instead of treating them as prefixes. That allows us to use options such as namespace.mapper while blocking the option name

I considered some other alternatives as well. For example

  • Using regular expressions in the forbidden prefixes -> that way one can specify whether it blocks a particular name or a prefix
  • Doing the validation differently for Kafka Connector configs

But the approach used in the PR (and described above) seemed best to me.


Apart from the actual fix, this PR also cleans up the various methods in AbstractConfiguration. It keeps only 3 constructors (one copy constructor and two regular ones) and makes it much easier to test this class as there are only two execution paths and not 8 of them.


This should resolve #10500.

Checklist

  • Write tests
  • Make sure all tests pass
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging

@scholzj scholzj added this to the 0.44.0 milestone Aug 27, 2024
@scholzj scholzj requested a review from ppatierno August 27, 2024 13:32
@scholzj
Copy link
Member Author

scholzj commented Aug 27, 2024

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

LGTM

@scholzj scholzj merged commit d0cb635 into strimzi:main Sep 2, 2024
21 checks passed
@scholzj scholzj deleted the allow-blocking-particular-options-and-not-just-prefixes-in-operand-configurations branch September 2, 2024 00:02
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.

[Bug]: The namespace.mapper configuration option of Mongodb Sink connector is reported as forbidden
3 participants