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 2ed8418 [FLINK-26996] Break the reconcile after first create session cluster 2ed8418 is described below commit 2ed8418da195af86a8f33d34f5acb7b6728a4ec2 Author: Aitozi <yuli....@alibaba-inc.com> AuthorDate: Sat Apr 2 20:49:13 2022 +0800 [FLINK-26996] Break the reconcile after first create session cluster --- .../operator/reconciler/SessionReconciler.java | 3 ++ .../operator/reconciler/SessionReconcilerTest.java | 59 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconciler.java b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconciler.java index 7192b12..525efd6 100644 --- a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconciler.java +++ b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconciler.java @@ -57,6 +57,8 @@ public class SessionReconciler extends BaseReconciler { flinkApp.getStatus() .setJobManagerDeploymentStatus(JobManagerDeploymentStatus.DEPLOYING); IngressUtils.updateIngressRules(flinkApp, effectiveConfig, kubernetesClient); + ReconciliationUtils.updateForSpecReconciliationSuccess(flinkApp, null); + return; } boolean specChanged = !flinkApp.getSpec().equals(lastReconciledSpec); @@ -64,6 +66,7 @@ public class SessionReconciler extends BaseReconciler { upgradeSessionCluster(flinkApp, effectiveConfig); IngressUtils.updateIngressRules(flinkApp, effectiveConfig, kubernetesClient); } + ReconciliationUtils.updateForSpecReconciliationSuccess(flinkApp, null); } diff --git a/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconcilerTest.java b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconcilerTest.java new file mode 100644 index 0000000..61b1f1c --- /dev/null +++ b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/reconciler/SessionReconcilerTest.java @@ -0,0 +1,59 @@ +/* + * 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.reconciler; + +import org.apache.flink.configuration.Configuration; +import org.apache.flink.kubernetes.operator.TestUtils; +import org.apache.flink.kubernetes.operator.TestingFlinkService; +import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration; +import org.apache.flink.kubernetes.operator.crd.FlinkDeployment; + +import io.javaoperatorsdk.operator.api.reconciler.Context; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** Tests for {@link SessionReconciler}. */ +public class SessionReconcilerTest { + + private final FlinkOperatorConfiguration operatorConfiguration = + FlinkOperatorConfiguration.fromConfiguration(new Configuration()); + + @Test + public void testStartSession() throws Exception { + Context context = TestUtils.createEmptyContext(); + var count = new AtomicInteger(0); + TestingFlinkService flinkService = + new TestingFlinkService() { + @Override + public void submitSessionCluster( + FlinkDeployment deployment, Configuration conf) { + super.submitSessionCluster(deployment, conf); + count.addAndGet(1); + } + }; + + SessionReconciler reconciler = + new SessionReconciler(null, flinkService, operatorConfiguration); + FlinkDeployment deployment = TestUtils.buildSessionCluster(); + reconciler.reconcile(deployment, context, new Configuration()); + assertEquals(1, count.get()); + } +}