srpraneeth commented on code in PR #682: URL: https://github.com/apache/flink-kubernetes-operator/pull/682#discussion_r1348082332
########## flink-kubernetes-operator-autoscaler/src/main/java/org/apache/flink/kubernetes/operator/autoscaler/validation/AutoScalerValidator.java: ########## @@ -0,0 +1,109 @@ +/* + * 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.kubernetes.operator.autoscaler.validation; + +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.kubernetes.operator.api.FlinkDeployment; +import org.apache.flink.kubernetes.operator.api.FlinkSessionJob; +import org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec; +import org.apache.flink.kubernetes.operator.autoscaler.config.AutoScalerOptions; +import org.apache.flink.kubernetes.operator.utils.FlinkUtils; +import org.apache.flink.kubernetes.operator.validation.FlinkResourceValidator; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Optional; + +/** Validator implementation for the AutoScaler from {@link Configuration}. */ +public class AutoScalerValidator implements FlinkResourceValidator { + + private static final Logger LOG = LoggerFactory.getLogger(FlinkUtils.class); + + @Override + public Optional<String> validateSessionJob( + FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) { + LOG.info("AutoScaler Configurations validator {}", sessionJob); + var spec = sessionJob.getSpec(); + if (spec.getFlinkConfiguration() != null) { + var flinkConfiguration = Configuration.fromMap(spec.getFlinkConfiguration()); + return validateAutoScalerFlinkConfiguration(flinkConfiguration); + } + return Optional.empty(); + } + + @Override + public Optional<String> validateDeployment(FlinkDeployment deployment) { + LOG.info("AutoScaler Configurations validator {}", deployment); Review Comment: I have added a check to validate only if the autoscaler is enabled. I added unit test and tested through e2e test to make sure that it works. Can you please explain what is default config for. I see that in the validator utils the default config is plugged in through a FlinkConfigManager (through constructor in DefaultValidator) but that may not be straight forward in case of AutoScalerValidator as AutoScalerValidator is not present in the operator module. It is discovered through ServiceLoader instead from the autoscaler module at runtime. I added a UT to make sure that with out the default config still the flinkConfiguration.get would get me the default value for the autoscaler configurations. Let me know if you still think I should add the default config I can look into it. -- 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