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

[feat][fn] Add option to merge secrets into config for sink/source #20863

Closed

Conversation

michaeljmarshall
Copy link
Member

@michaeljmarshall michaeljmarshall commented Jul 24, 2023

Fixes #20862

Motivation

See the issue for detailed motivation. Briefly, the current solution for configuring sinks and sources requires each sink and source to implement calls to materialize secrets using the SecretsProvider. Instead of relying on each connector to implement this feature, this PR introduces an option to pass the configuration into the sink and source open method call, so that the secrets are available without needing them to be passed in as plain text.

One major benefit of this solution is that it integrates with the existing functionality to pass in secrets.

In order to be backwards compatible, I followed the approach used by #20116 to add a configuration to the function worker that will apply to all sinks/sources created by the function worker.

Example for old configuration and new configuration:

 bin/pulsar-admin sinks create --input-specs "spec with secret"
bin/pulsar-admin sinks create --input-specs "spec without secret" --secrets "secret reference"

Modifications

  • Add the option to merge a connector's secrets map into the config map that is subsequently passed to the sink or source when calling open.
  • Add a new configuration to the function worker (mergeSecretsIntoConfigMap) and an associated new parameter to the JavaInstanceStarter (--merge_secrets_into_config_map) to enable this feature. The default value keeps the current behavior.

Verifying this change

This change added tests.

Does this pull request potentially affect one of the following parts:

Adds a new configuration option. It is backwards compatible and defaults to use the old behavior.

Documentation

  • doc-required

I'll need a PR to add docs for this feature.

Matching PR in forked repository

PR in forked repository: michaeljmarshall#53

@michaeljmarshall michaeljmarshall added type/feature The PR added a new feature or issue requested a new feature area/function area/security labels Jul 24, 2023
@michaeljmarshall michaeljmarshall added this to the 3.2.0 milestone Jul 24, 2023
@michaeljmarshall michaeljmarshall self-assigned this Jul 24, 2023
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Jul 24, 2023
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

I have one question: how does this work with structured configurations ? A value in the configuration may be a Map, is it possible to update entries inside a nested map?

@@ -158,6 +158,15 @@ public class JavaInstanceStarter implements AutoCloseable {
required = false)
public Boolean ignoreUnknownConfigFields = false;

@Parameter(names = "--merge_secrets_into_config_map", arity = 1,
description = "Whether to merge secrets into the connector's configuration. Only affects Sinks and Sources."
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this doesn't apply to Functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could apply to functions. I targeted Sources and Sinks because those are often cases where you are running a third party connector and in those cases, it is easier to merge the configs than updating the code. In the function runtime, it seems to be a well defined flow to get a secret from the function's context. That being said, we could also just fix each implementation.

I provide some direct examples of issues with connectors in this comment #20862 (comment).

@michaeljmarshall
Copy link
Member Author

how does this work with structured configurations ? A value in the configuration may be a Map, is it possible to update entries inside a nested map?

The current logic is a naive putIfAbsent. Is it common to have nested maps? Would it always be valid to insert a sub-map?

@michaeljmarshall
Copy link
Member Author

@eolivelli - looks like recursive secret interpolation would be valuable here:

@FieldDoc(
defaultValue = "",
help = "Config properties to pass to the kafka connector.")
private Map<String, String> kafkaConnectorConfigProperties;

@michaeljmarshall
Copy link
Member Author

This will be superseded by the outcome of PIP 289. My preference is to use #20901.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/function area/security doc-required Your PR changes impact docs and you will update later. type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic Secret Injection for Connector Configuration
2 participants