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

[FLINK-36974]support overwrite flink config by command line #3823

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

Conversation

hiliuxg
Copy link
Contributor

@hiliuxg hiliuxg commented Dec 28, 2024

Support overwrite flink config in the command line, for example:

bin/flink-cdc.sh1732864461789.yaml --flink-conf execution.checkpointing.interval=10min --flink-conf rest.bind-port=42689 --flink-conf yarn.application.id=application_1714009558476_3563 --flink-conf execution.target=yarn-session --flink-conf rest.bind-address=10.5.140.140

The example provided is used to submit a job to a specified host's YARN session cluster with specific Flink configurations.

@github-actions github-actions bot added the cli label Dec 28, 2024
@hiliuxg hiliuxg changed the title support overwrite flink config by command line [FLINK-36974]support overwrite flink config by command line Dec 28, 2024
Copy link
Contributor

@yuxiqian yuxiqian left a comment

Choose a reason for hiding this comment

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

Thanks for @hiliuxg's nice work! Just left some trivial comments.

Comment on lines 167 to 171
assertThat(configMap.get("execution.target")).isEqualTo("yarn-session");
assertThat(configMap.get("rest.bind-port")).isEqualTo("42689");
assertThat(configMap.get("yarn.application.id"))
.isEqualTo("application_1714009558476_3563");
assertThat(configMap.get("rest.bind-address")).isEqualTo("10.1.140.140");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertThat(configMap.get("execution.target")).isEqualTo("yarn-session");
assertThat(configMap.get("rest.bind-port")).isEqualTo("42689");
assertThat(configMap.get("yarn.application.id"))
.isEqualTo("application_1714009558476_3563");
assertThat(configMap.get("rest.bind-address")).isEqualTo("10.1.140.140");
assertThat(configMap)
.containsEntry("execution.target", "yarn-session")
.containsEntry("rest.bind-port", "42689")
.containsEntry("yarn.application.id", "application_1714009558476_3563")
.containsEntry("rest.bind-address", "10.1.140.140");

Comment on lines 97 to 98
public static final Option FLINK_CONFIG =
Option.builder("fc")
Copy link
Contributor

Choose a reason for hiding this comment

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

SQL Client provides -D to pass extra Flink options dynamically. Maybe we can follow the same naming here?

Configuration flinkConfig, CommandLine commandLine) {
String[] flinkConfigs = commandLine.getOptionValues(FLINK_CONFIG);
if (flinkConfigs != null) {
LOG.info("Find flink config items: {}", String.join(",", flinkConfigs));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.info("Find flink config items: {}", String.join(",", flinkConfigs));
LOG.info("Dynamic flink config items found: {}", flinkConfigs);

Comment on lines 129 to 130
String key = config.split("=")[0].trim();
String value = config.split("=")[1].trim();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can split just once and verify the format first.

@@ -145,6 +146,31 @@ void testPipelineExecuting() throws Exception {
assertThat(executionInfo.getDescription()).isEqualTo("fake-description");
}

@Test
void testPipelineExecutingWithFlinkConfig() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also add tests for malformed arguments (like when = is missing, or = is part of value, etc.)

@hiliuxg
Copy link
Contributor Author

hiliuxg commented Jan 7, 2025

Hi @yuxiqian, thanks for the review. I have accepted your suggestions and made the necessary modifications. Please review again when you have time. thanks .

@hiliuxg
Copy link
Contributor Author

hiliuxg commented Jan 7, 2025

hi @yuxiqian , thank you for your guidance. I have made another version of the code. Please review it again when you have time.

Copy link
Contributor

@yuxiqian yuxiqian left a comment

Choose a reason for hiding this comment

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

Looks nice! Thanks for @hiliuxg's quick response.

Could @leonardBang @ruanhang1993 trigger the CI please?

String value = properties.getProperty(key);
if (StringUtils.isNullOrWhitespaceOnly(key)
|| StringUtils.isNullOrWhitespaceOnly(value)) {
throw new IllegalArgumentException("Illegal argument for key or value");
Copy link
Contributor

@yuxiqian yuxiqian Jan 7, 2025

Choose a reason for hiding this comment

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

nit: maybe we can also print out the questionable key / value pair in command line to improve exception traceability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. thanks for comment

@yuxiqian
Copy link
Contributor

yuxiqian commented Jan 7, 2025

@hiliuxg Seems there are some test cases in org.apache.flink.cdc.cli.CliFrontendTest that needs to be updated.

@yuxiqian
Copy link
Contributor

yuxiqian commented Jan 8, 2025

@hiliuxg org.apache.flink.cdc.cli.CliFrontendTest#testGeneratingHelpMessage and org.apache.flink.cdc.cli.CliFrontendTest#testNoArgument is still failing, presumably because -D <Session dynamic flink config key=val> is so long that output format is changed.

Also, could you please rebase this branch to latest master?

Copy link
Contributor

@Jzjsnow Jzjsnow left a comment

Choose a reason for hiding this comment

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

I think the HELP_MESSAGE in CliFrontendTest should also be updated to include the -D parameter.

@@ -145,6 +147,70 @@ void testPipelineExecuting() throws Exception {
assertThat(executionInfo.getDescription()).isEqualTo("fake-description");
}

@Test
void testPipelineExecutingWithFlinkConfig() throws Exception {
Copy link
Contributor

@Jzjsnow Jzjsnow Jan 9, 2025

Choose a reason for hiding this comment

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

I'm wondering if we need to add some more cases that test for the concatenation of “-D” and key=value pairs instead of space-separated pairs, such as "-Dexecution.target= yarn-session". I'm concerned that there are cases that might not be recognized, such as "-D=execution.target".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants