mxm commented on code in PR #729:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/729#discussion_r1424043535
##########
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:
The O(n) complexity of both approaches is the same. I still prefer the first
commit in this PR.
--
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]