You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "JunRuiLee (via GitHub)" <gi...@apache.org> on 2024/08/22 09:22:42 UTC
[PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
JunRuiLee opened a new pull request, #25234:
URL: https://github.com/apache/flink/pull/25234
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
This pr introduces breaking changes that will be included in FLINK-2.0: Remove flink-conf.yaml from flink dist.
## Brief change log
Remove flink-conf.yaml from flink dist.
## Verifying this change
This change is already covered by existing tests.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no**)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #25234:
URL: https://github.com/apache/flink/pull/25234#discussion_r1751622778
##########
flink-core/src/test/java/org/apache/flink/configuration/ConfigurationFileMigrationUtilsTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.configuration;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ConfigurationFileMigrationUtilsTest {
+
+ @TempDir private File tmpDir;
+
+ @Test
+ void testConfigurationWithLegacyYAML() throws FileNotFoundException {
+ File confFile =
+ new File(tmpDir, ConfigurationFileMigrationUtils.LEGACY_FLINK_CONF_FILENAME);
+ try (PrintWriter pw = new PrintWriter(confFile)) {
+ pw.println("###########################"); // should be skipped
+ pw.println("# Some : comments : to skip"); // should be skipped
+ pw.println("###########################"); // should be skipped
+ pw.println("mykey1: myvalue1"); // OK, simple correct case
+ pw.println("mykey2 : myvalue2"); // OK, whitespace before colon is correct
+ pw.println("mykey3:myvalue3"); // SKIP, missing white space after colon
+ pw.println(" some nonsense without colon and whitespace separator"); // SKIP
+ pw.println(" : "); // SKIP
+ pw.println(" "); // SKIP (silently)
+ pw.println(" "); // SKIP (silently)
+ pw.println("mykey4: myvalue4# some comments"); // OK, skip comments only
+ pw.println(" mykey5 : myvalue5 "); // OK, trim unnecessary whitespace
+ pw.println("mykey6: my: value6"); // OK, only use first ': ' as separator
+ pw.println("mykey7: "); // SKIP, no value provided
+ pw.println(": myvalue8"); // SKIP, no key provided
+
+ pw.println("mykey9: myvalue9"); // OK
+ pw.println("mykey9: myvalue10"); // OK, overwrite last value
+ }
+
+ Map<String, String> conf = ConfigurationFileMigrationUtils.loadLegacyYAMLResource(confFile);
+
+ // all distinct keys from confFile1 + confFile2 key
+ assertThat(conf.keySet()).hasSize(6);
+
+ // keys 1, 2, 4, 5, 6, 7, 8 should be OK and match the expected values
+ assertThat(conf.getOrDefault("mykey1", null)).isEqualTo("myvalue1");
+ assertThat(conf.getOrDefault("mykey1", null)).isEqualTo("myvalue1");
+ assertThat(conf.getOrDefault("mykey2", null)).isEqualTo("myvalue2");
+ assertThat(conf.getOrDefault("mykey3", "null")).isEqualTo("null");
+ assertThat(conf.getOrDefault("mykey4", null)).isEqualTo("myvalue4");
+ assertThat(conf.getOrDefault("mykey5", null)).isEqualTo("myvalue5");
+ assertThat(conf.getOrDefault("mykey6", null)).isEqualTo("my: value6");
+ assertThat(conf.getOrDefault("mykey7", "null")).isEqualTo("null");
+ assertThat(conf.getOrDefault("mykey8", "null")).isEqualTo("null");
+ assertThat(conf.getOrDefault("mykey9", null)).isEqualTo("myvalue10");
+ }
+
+ @Test
+ // We allow malformed YAML files if loaded legacy flink conf
Review Comment:
loaded -> loading
##########
flink-python/pyflink/pyflink_gateway_server.py:
##########
@@ -46,32 +46,13 @@ def on_windows():
def read_from_config(key, default_value, flink_conf_directory):
from ruamel.yaml import YAML
yaml = YAML(typ='safe')
- # try to find flink-conf.yaml file in flink_conf_directory
- flink_conf_file = os.path.join(flink_conf_directory, "flink-conf.yaml")
- if os.path.isfile(flink_conf_file):
- # If flink-conf.yaml exists, use the old parsing logic to read the value
- # get the realpath of tainted path value to avoid CWE22 problem that constructs a path
- # or URI using the tainted value and might allow an attacker to access, modify, or test
- # the existence of critical or sensitive files.
- with open(os.path.realpath(flink_conf_file), "r") as f:
- while True:
- line = f.readline()
- if not line:
- break
- if line.startswith("#") or len(line.strip()) == 0:
- continue
- k, v = line.split(":", 1)
- if k.strip() == key:
- return v.strip()
- else:
- # If flink-conf.yaml does not exist, try to find config.yaml instead
- config_file = os.path.join(flink_conf_directory, "config.yaml")
- if os.path.isfile(config_file):
- # If config.yaml exists, use YAML parser to read the value
- with open(os.path.realpath(config_file), "r") as f:
- config = yaml.load(f)
- flat_config = flatten_config(config)
- return flat_config.get(key, default_value)
+ config_file = os.path.join(flink_conf_directory, "config.yaml")
+ if os.path.isfile(config_file):
+ # If config.yaml exists, use YAML parser to read the value
+ with open(os.path.realpath(config_file), "r") as f:
+ config = yaml.load(f)
+ flat_config = flatten_config(config)
+ return flat_config.get(key, default_value)
# If neither file exists, return the default value
Review Comment:
The comment is outdated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2327737516
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk commented on code in PR #25234:
URL: https://github.com/apache/flink/pull/25234#discussion_r1741626266
##########
flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java:
##########
@@ -45,6 +45,11 @@ public final class GlobalConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(GlobalConfiguration.class);
+ /**
+ * @deprecated This file is deprecated and is only used to help users migrate their legacy
+ * configuration files to the new configuration file `config.yaml`.
+ */
+ @Deprecated @VisibleForTesting
Review Comment:
How about to introduce a separate `ConfigurationFileMigrationUtils` class? It can be the only place to host logics which recognizes the legacy file.
##########
flink-core/src/main/java/org/apache/flink/configuration/GlobalConfiguration.java:
##########
@@ -143,31 +155,54 @@ public static Configuration loadConfiguration(
}
// get Flink yaml configuration file
- File yamlConfigFile = new File(confDirFile, LEGACY_FLINK_CONF_FILENAME);
Configuration configuration;
-
- if (!yamlConfigFile.exists()) {
- yamlConfigFile = new File(confDirFile, FLINK_CONF_FILENAME);
+ if (loadLegacyConfigFile) {
+ File yamlConfigFile = new File(confDirFile, LEGACY_FLINK_CONF_FILENAME);
Review Comment:
I prefer that the `GlobalConfiguration` code no longer see nor operate on the legacy config file, just like mentioned in the comment above.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/util/ConfigurationParserUtils.java:
##########
@@ -230,13 +228,9 @@ public static List<String> migrateLegacyConfigurationToStandardYaml(
throw e;
}
- checkState(
Review Comment:
Why removing this check?
##########
flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/BootstrapToolsTest.java:
##########
@@ -298,8 +298,15 @@ private void testWriteConfigurationAndReloadInternal(boolean standardYaml) throw
BootstrapTools.writeConfiguration(
flinkConfig, new File(flinkConfDir, GlobalConfiguration.getFlinkConfFilename()));
- final Configuration loadedFlinkConfig =
- GlobalConfiguration.loadConfiguration(flinkConfDir.getAbsolutePath());
+ final Configuration loadedFlinkConfig;
+ if (standardYaml) {
+ loadedFlinkConfig =
+ GlobalConfiguration.loadConfiguration(flinkConfDir.getAbsolutePath());
+ } else {
+ loadedFlinkConfig =
Review Comment:
We should not test cases that will not happen in production.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2326106286
@zhuzhurk, thanks for the review, I've updated this pr accordingly, PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2326381803
I've updated the PR to completely remove the standard YAML flag from the code.
Additionally, I've removed the setStandardYaml calls from `RocksDBStateBackendConfigTest#testConfigureForStCompressionPerLevel `and `ForStStateBackendConfigTest#testConfigureForStCompressionPerLevel`, as discussed with @Zakelly. Although this case is inconsistent with previous behavior, it remains meaningful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2327822411
> I've updated the PR to completely remove the standard YAML flag from the code. Additionally, I've removed the setStandardYaml calls from `RocksDBStateBackendConfigTest#testConfigureForStCompressionPerLevel `and `ForStStateBackendConfigTest#testConfigureForStCompressionPerLevel`, as discussed with @Zakelly. Although this case is inconsistent with previous behavior, it remains meaningful.
+1 for this part.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "zhuzhurk (via GitHub)" <gi...@apache.org>.
zhuzhurk closed pull request #25234: [FLINK-33677][core] Remove flink-conf.yaml from flink dist.
URL: https://github.com/apache/flink/pull/25234
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2304202607
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f06d7bce9109592d2488809323a859e40dc0478",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6f06d7bce9109592d2488809323a859e40dc0478",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f06d7bce9109592d2488809323a859e40dc0478 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33677][core] Remove flink-conf.yaml from flink dist. [flink]
Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee commented on PR #25234:
URL: https://github.com/apache/flink/pull/25234#issuecomment-2340215104
Thanks @zhuzhurk , I've updated this pr accordingly, PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org