mxm commented on code in PR #729: URL: https://github.com/apache/flink-kubernetes-operator/pull/729#discussion_r1424363838
########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/config/AutoScalerOptions.java: ########## @@ -247,21 +222,41 @@ private static ConfigOptions.OptionBuilder autoScalerConfig(String key) { .stringType() .asList() .defaultValues() - .withFallbackKeys(oldOperatorConfigKey("vertex.exclude.ids")) .withDescription( "A (semicolon-separated) list of vertex ids in hexstring for which to disable scaling. Caution: For non-sink vertices this will still scale their downstream operators until https://issues.apache.org/jira/browse/FLINK-31215 is implemented."); public static final ConfigOption<Duration> SCALING_EVENT_INTERVAL = autoScalerConfig("scaling.event.interval") .durationType() .defaultValue(Duration.ofMinutes(30)) - .withFallbackKeys(oldOperatorConfigKey("scaling.event.interval")) .withDescription("Time interval to resend the identical event"); public static final ConfigOption<Duration> FLINK_CLIENT_TIMEOUT = autoScalerConfig("flink.rest-client.timeout") .durationType() .defaultValue(Duration.ofSeconds(10)) - .withFallbackKeys(oldOperatorConfigKey("flink.rest-client.timeout")) .withDescription("The timeout for waiting the flink rest client to return."); + + /** Migrate config keys still prefixed with the old Kubernetes operator prefix. */ + public static Configuration migrateOldConfigKeys(Configuration config) { + Preconditions.checkNotNull(config); + config = new Configuration(config); + + Set<String> toBeMigrated = new HashSet<>(); + for (String key : config.keySet()) { + if (key.startsWith(LEGACY_CONF_PREFIX)) { + toBeMigrated.add(key); + } + } + for (String key : toBeMigrated) { + String migratedKey = key.substring(LEGACY_CONF_PREFIX.length()); + boolean keyDoesNotExist = config.getString(migratedKey, null) == null; + if (keyDoesNotExist) { + String migratedValue = Preconditions.checkNotNull(config.getString(key, null)); + config.setString(migratedKey, migratedValue); + } + config.removeKey(key); + } + return config; + } Review Comment: There are a lot of copy steps with this approach because `toMap()` converts every single value before it inserts it into the new map. `new Configuration(config)` directly passes on the internal map. With that in mind, I tried incorporating your code suggestions, i.e. do a single pass. -- 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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org