This is an automated email from the ASF dual-hosted git repository. gyfora pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push: new 27fd3e8 [hotfix] Fix pod template merging if base template is null 27fd3e8 is described below commit 27fd3e83a3c0cec6fbde7b83461ccb684010ad3e Author: Gyula Fora <g_f...@apple.com> AuthorDate: Wed Feb 23 15:10:42 2022 +0100 [hotfix] Fix pod template merging if base template is null --- .../kubernetes/operator/utils/FlinkConfigBuilder.java | 17 ++++++++++------- .../operator/utils/FlinkConfigBuilderTest.java | 5 ++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilder.java b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilder.java index e117d89..f55a1f1 100644 --- a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilder.java +++ b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilder.java @@ -201,14 +201,17 @@ public class FlinkConfigBuilder { private static void setPodTemplate( Pod basicPod, Pod appendPod, Configuration effectiveConfig, boolean isJM) throws IOException { - if (basicPod != null) { - final ConfigOption<String> podConfigOption = - isJM - ? KubernetesConfigOptions.JOB_MANAGER_POD_TEMPLATE - : KubernetesConfigOptions.TASK_MANAGER_POD_TEMPLATE; - effectiveConfig.setString( - podConfigOption, createTempFile(mergePodTemplates(basicPod, appendPod))); + + if (basicPod == null && appendPod == null) { + return; } + + final ConfigOption<String> podConfigOption = + isJM + ? KubernetesConfigOptions.JOB_MANAGER_POD_TEMPLATE + : KubernetesConfigOptions.TASK_MANAGER_POD_TEMPLATE; + effectiveConfig.setString( + podConfigOption, createTempFile(mergePodTemplates(basicPod, appendPod))); } private static String createTempFile(Pod podTemplate) throws IOException { diff --git a/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilderTest.java b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilderTest.java index 1e4caa2..86c06d7 100644 --- a/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilderTest.java +++ b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/utils/FlinkConfigBuilderTest.java @@ -156,8 +156,11 @@ public class FlinkConfigBuilderTest { @Test public void testApplyTaskManagerSpec() throws Exception { + FlinkDeployment deploymentClone = TestUtils.clone(flinkDeployment); + deploymentClone.getSpec().setPodTemplate(null); + final Configuration configuration = - new FlinkConfigBuilder(flinkDeployment).applyTaskManagerSpec().build(); + new FlinkConfigBuilder(deploymentClone).applyTaskManagerSpec().build(); final Pod tmPod = OBJECT_MAPPER.readValue( new File(