wenjin272 commented on code in PR #1337:
URL: https://github.com/apache/flink-agents/pull/1337#discussion_r4419831489


##########
runtime/src/main/java/org/apache/flink/agents/runtime/env/RemoteExecutionEnvironment.java:
##########
@@ -119,10 +127,34 @@ public static AgentConfiguration 
loadAgentConfiguration(String configDir) {
             if (configDir == null) {
                 return new AgentConfiguration();
             }
-            final Map<String, Object> configData =
-                    (Map<String, Object>)
-                            YamlParserUtils.loadYamlFile(new File(configDir, 
FLINK_CONF_FILENAME))
-                                    .getOrDefault("agent", new HashMap<>());
+            File configFile = new File(configDir, FLINK_CONF_FILENAME);
+            if (!configFile.exists()) {
+                File legacyConfigFile = new File(configDir, 
LEGACY_FLINK_CONF_FILENAME);
+                if (legacyConfigFile.exists()) {
+                    LOG.warn(
+                            "{} not found in {}, using legacy config file {}",
+                            FLINK_CONF_FILENAME,
+                            configDir,
+                            LEGACY_FLINK_CONF_FILENAME);
+                    configFile = legacyConfigFile;
+                }
+            }
+
+            final Map<String, Object> yaml = 
YamlParserUtils.loadYamlFile(configFile);

Review Comment:
   Yes, I think we should align both Java and Python with Flink’s configuration 
loading rules:
   
   - **Flink 1.20:** prefer `flink-conf.yaml`, falling back to `config.yaml`.
   - **Flink 2.x:** read only `config.yaml`.
   - Parse `flink-conf.yaml` using legacy rules and `config.yaml` using 
standard YAML rules.
   
   So nested `agent:` blocks are supported in `config.yaml` on both 1.20 and 
2.x, rather than only on 2.x.
   
   This does require changing the existing Python behavior and implementing a 
small Python legacy parser matching Flink’s 
`GlobalConfiguration.loadLegacyYAMLResource()`, so Java and Python behave 
consistently.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to