-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][io] Improve loading sensitive fields for many connectors #20902
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
base: master
Are you sure you want to change the base?
Changes from all commits
fb25067
067f1c0
5fe7790
e222586
1d10480
dcb25f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| */ | ||
| package org.apache.pulsar.io.aerospike; | ||
|
|
||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
| import java.io.File; | ||
|
|
@@ -26,6 +27,9 @@ | |
| import java.util.Map; | ||
| import lombok.Data; | ||
| import lombok.experimental.Accessors; | ||
| import org.apache.pulsar.io.common.IOConfigUtils; | ||
| import org.apache.pulsar.io.core.SinkContext; | ||
| import org.apache.pulsar.io.core.annotations.FieldDoc; | ||
|
|
||
| @Data | ||
| @Accessors(chain = true) | ||
|
|
@@ -38,21 +42,50 @@ public class AerospikeSinkConfig implements Serializable { | |
| private String columnName; | ||
|
|
||
| // Optional | ||
| @FieldDoc( | ||
| required = false, | ||
| defaultValue = "", | ||
| sensitive = true, | ||
| help = "The username for authentication." | ||
| ) | ||
| private String userName; | ||
| @FieldDoc( | ||
| required = false, | ||
| defaultValue = "", | ||
| sensitive = true, | ||
| help = "The password for authentication." | ||
| ) | ||
| private String password; | ||
| private String keySet; | ||
| private int maxConcurrentRequests = 100; | ||
| private int timeoutMs = 100; | ||
| private int retries = 1; | ||
|
|
||
|
|
||
| /** | ||
| * @deprecated Use {@link #load(String, SinkContext)} instead. | ||
| */ | ||
| @Deprecated | ||
| public static AerospikeSinkConfig load(String yamlFile) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
| return mapper.readValue(new File(yamlFile), AerospikeSinkConfig.class); | ||
| } | ||
|
|
||
| public static AerospikeSinkConfig load(String yamlFile, SinkContext context) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
| return load(mapper.readValue(new File(yamlFile), new TypeReference<Map<String, Object>>() {}), context); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Use {@link #load(Map, SinkContext)} instead. | ||
| */ | ||
| @Deprecated | ||
| public static AerospikeSinkConfig load(Map<String, Object> map) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
| return mapper.readValue(mapper.writeValueAsString(map), AerospikeSinkConfig.class); | ||
| } | ||
|
|
||
| public static AerospikeSinkConfig load(Map<String, Object> map, SinkContext context) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should just keep the method, all other
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am conflicted about removing those
What exactly is the connector framework's responsibility?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For each connector, no user to use its class, right? We just need to make sure that the configuration is compatible. I don't think removing these public methods would be a breaking change.
The io framework is responsible for loading the configuration from the YAML and converting it to the Map. So for the connector, we only need cover to deserialize the correct configuration from the Map.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think you're right here. Part of the issue is likely the ambiguous boundaries for users. It's probably possible to use this class as a dependency in another project, but I doubt there is really an expectation that these classes are meant to be used elsewhere. The primary risk would be for someone slightly modifying a connector.
As long as we assume these classes are for pulsar's internal use, I agree that this is the framework's responsibility. The last question is really whether we think this change is valuable. @eolivelli is asking in another comment on this PR whether this is the right design.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe we can discuss clearly where the boundaries we offer to users are. I don't think users should use this class as a dependency in another project. We shouldn't have uploaded the connector project to the Maven center, right?
Maybe the IO framework needs to deserialize the configuration object for the connector. |
||
| return IOConfigUtils.loadWithSecrets(map, AerospikeSinkConfig.class, context); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| */ | ||
| package org.apache.pulsar.io.canal; | ||
|
|
||
| import com.fasterxml.jackson.core.type.TypeReference; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
| import java.io.File; | ||
|
|
@@ -26,6 +27,8 @@ | |
| import java.util.Map; | ||
| import lombok.Data; | ||
| import lombok.experimental.Accessors; | ||
| import org.apache.pulsar.io.common.IOConfigUtils; | ||
| import org.apache.pulsar.io.core.SourceContext; | ||
| import org.apache.pulsar.io.core.annotations.FieldDoc; | ||
|
|
||
|
|
||
|
|
@@ -80,14 +83,31 @@ public class CanalSourceConfig implements Serializable{ | |
| help = "The batch size to fetch from canal.") | ||
| private int batchSize = 1000; | ||
|
|
||
|
|
||
| /** | ||
| * @deprecated Use {@link #load(String, SourceContext)} instead. | ||
| */ | ||
| @Deprecated | ||
| public static CanalSourceConfig load(String yamlFile) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
| return mapper.readValue(new File(yamlFile), CanalSourceConfig.class); | ||
| } | ||
|
|
||
| public static CanalSourceConfig load(String yamlFile, SourceContext context) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
| return load(mapper.readValue(new File(yamlFile), new TypeReference<Map<String, Object>>() {}), context); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Use {@link #load(Map, SourceContext)} instead. | ||
| */ | ||
| @Deprecated | ||
| public static CanalSourceConfig load(Map<String, Object> map) throws IOException { | ||
| ObjectMapper mapper = new ObjectMapper(); | ||
| return mapper.readValue(mapper.writeValueAsString(map), CanalSourceConfig.class); | ||
| } | ||
|
|
||
| public static CanalSourceConfig load(Map<String, Object> map, SourceContext context) { | ||
| return IOConfigUtils.loadWithSecrets(map, CanalSourceConfig.class, context); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about adding a method in Context?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this is not the ideal solution. I wrote this PR to complete the paradigm started in the project for some but not all connectors. There are already several examples using this "flow", which is to convert the |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connectors shouldn't bundle Pulsar IO jars.
This must be scope 'provided'
Are we breaking compatibility with existing connectors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this block from existing connectors. Should I fix it for all of them?