xintongsong commented on a change in pull request #14629: URL: https://github.com/apache/flink/pull/14629#discussion_r579634054
########## File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/factory/KubernetesJobManagerFactoryWithPodTemplateTest.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.kubeclient.factory; + +import org.apache.flink.kubernetes.KubernetesPodTemplateTestUtils; +import org.apache.flink.kubernetes.configuration.KubernetesConfigOptionsInternal; +import org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint; +import org.apache.flink.kubernetes.kubeclient.FlinkPod; +import org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification; +import org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerTestBase; +import org.apache.flink.kubernetes.utils.Constants; +import org.apache.flink.kubernetes.utils.KubernetesUtils; + +import io.fabric8.kubernetes.api.model.Container; +import io.fabric8.kubernetes.api.model.PodTemplateSpec; +import org.junit.Test; + +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +/** + * General tests for the {@link KubernetesJobManagerFactory} with pod template. These tests will + * ensure that init container, volumes, sidecar containers from pod template should be kept after + * all decorators. + */ +public class KubernetesJobManagerFactoryWithPodTemplateTest extends KubernetesJobManagerTestBase { Review comment: The two classes `KubernetesJobManagerFactoryWithPodTemplateTest` and `KubernetesTaskManagerFactoryWithPodTemplateTest` are practically identical, except for `onSetup`. I think they can be deduplicated. ########## File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java ########## @@ -367,6 +368,46 @@ code("FlinkKubeClient#checkAndUpdateConfigMap")) .build()); + public static final ConfigOption<String> JOB_MANAGER_POD_TEMPLATE = + key("kubernetes.jobmanager.pod-template-file") + .stringType() + .noDefaultValue() + .withFallbackKeys(KUBERNETES_POD_TEMPLATE_FILE_KEY) + .withDescription( + "Specify a local file that contains the jobmanager pod template. It will be used to " + + "initialize the jobmanager pod. If not explicitly configured, config option '" + + KUBERNETES_POD_TEMPLATE_FILE_KEY + + "' will be used."); + + public static final ConfigOption<String> TASK_MANAGER_POD_TEMPLATE = + key("kubernetes.taskmanager.pod-template-file") + .stringType() + .noDefaultValue() + .withFallbackKeys(KUBERNETES_POD_TEMPLATE_FILE_KEY) + .withDescription( + "Specify a local file that contains the taskmanager pod template. It will be used to " + + "initialize the taskmanager pod. If not explicitly configured, config option '" + + KUBERNETES_POD_TEMPLATE_FILE_KEY + + "' will be used."); + + /** + * This option is here only for documentation generation, it is the fallback key of + * JOB_MANAGER_POD_TEMPLATE and TASK_MANAGER_POD_TEMPLATE. + */ + @SuppressWarnings("unused") + public static final ConfigOption<String> KUBERNETES_POD_TEMPLATE = + key(KUBERNETES_POD_TEMPLATE_FILE_KEY) + .stringType() + .noDefaultValue() + .withDescription( Review comment: Shall we explain in the configuration option description that the template should use `Constants.MAIN_CONTAINER_NAME` to refer the main container? ########## File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/configuration/KubernetesConfigOptions.java ########## @@ -367,6 +368,46 @@ code("FlinkKubeClient#checkAndUpdateConfigMap")) .build()); + public static final ConfigOption<String> JOB_MANAGER_POD_TEMPLATE = + key("kubernetes.jobmanager.pod-template-file") Review comment: Minor: I'd suggest to align the option keys as: * kubernetes.pod-template-file * kubernetes.pod-template-file.jobmanager * kubernetes.pod-template-file.taskmanager ########## File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecoratorWithPodTemplateTest.java ########## @@ -0,0 +1,197 @@ +/* + * 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.kubeclient.decorators; + +import org.apache.flink.kubernetes.KubernetesPodTemplateTestUtils; +import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions; +import org.apache.flink.kubernetes.kubeclient.FlinkPod; +import org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerTestBase; +import org.apache.flink.kubernetes.utils.Constants; +import org.apache.flink.kubernetes.utils.KubernetesUtils; + +import io.fabric8.kubernetes.api.model.Container; +import io.fabric8.kubernetes.api.model.EnvVar; +import io.fabric8.kubernetes.api.model.LocalObjectReference; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.Quantity; +import io.fabric8.kubernetes.api.model.ResourceRequirements; +import io.fabric8.kubernetes.api.model.Toleration; +import org.hamcrest.Matchers; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +/** + * Tests of merging and overwriting Kubernetes fields from {@link KubernetesConfigOptions} and pod + * template for the {@link InitJobManagerDecorator}. + */ +public class InitJobManagerDecoratorWithPodTemplateTest extends KubernetesJobManagerTestBase { Review comment: `InitJobManagerDecoratorWithPodTemplateTest` and `InitTaskManagerDecoratorWithPodTemplateTest` should also be deduplicated. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
