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 56b88174 [FLINK-40550] Fix operator crash when reconcile.parallelism 
is -1
56b88174 is described below

commit 56b8817496f0d7d6c1a9d1039d53ea5ea2313937
Author: Purushottam Sinha <[email protected]>
AuthorDate: Tue Sep 15 00:34:32 2026 +0530

    [FLINK-40550] Fix operator crash when reconcile.parallelism is -1
---
 .../service/FlinkResourceContextFactory.java       |  8 +--
 .../service/FlinkResourceContextFactoryTest.java   | 59 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 3 deletions(-)

diff --git 
a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactory.java
 
b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactory.java
index 32af44fb..58be43e2 100644
--- 
a/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactory.java
+++ 
b/flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactory.java
@@ -86,10 +86,12 @@ public class FlinkResourceContextFactory {
         this.operatorMetricGroup = operatorMetricGroup;
         this.eventRecorder = eventRecorder;
         this.artifactManager = new ArtifactManager(configManager);
+        int parallelism = 
configManager.getOperatorConfiguration().getReconcilerMaxParallelism();
+        var threadFactory = new 
ExecutorThreadFactory("Flink-RestClusterClient-IO");
         this.clientExecutorService =
-                Executors.newFixedThreadPool(
-                        
configManager.getOperatorConfiguration().getReconcilerMaxParallelism(),
-                        new 
ExecutorThreadFactory("Flink-RestClusterClient-IO"));
+                parallelism == -1
+                        ? Executors.newCachedThreadPool(threadFactory)
+                        : Executors.newFixedThreadPool(parallelism, 
threadFactory);
     }
 
     public FlinkStateSnapshotContext getFlinkStateSnapshotContext(
diff --git 
a/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactoryTest.java
 
b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactoryTest.java
new file mode 100644
index 00000000..1eb8fe4b
--- /dev/null
+++ 
b/flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/service/FlinkResourceContextFactoryTest.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.service;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.kubernetes.operator.TestUtils;
+import org.apache.flink.kubernetes.operator.config.FlinkConfigManager;
+import 
org.apache.flink.kubernetes.operator.config.KubernetesOperatorConfigOptions;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+/** Tests for {@link FlinkResourceContextFactory}. */
+public class FlinkResourceContextFactoryTest {
+
+    @Test
+    public void testUnboundedReconcileParallelismDoesNotCrashFactory() {
+        var conf = new Configuration();
+        
conf.set(KubernetesOperatorConfigOptions.OPERATOR_RECONCILE_PARALLELISM, -1);
+        var configManager = new FlinkConfigManager(conf);
+
+        assertDoesNotThrow(
+                () ->
+                        new FlinkResourceContextFactory(
+                                configManager,
+                                TestUtils.createTestMetricGroup(new 
Configuration()),
+                                null));
+    }
+
+    @Test
+    public void testFixedReconcileParallelismConstructsFactory() {
+        var conf = new Configuration();
+        
conf.set(KubernetesOperatorConfigOptions.OPERATOR_RECONCILE_PARALLELISM, 4);
+        var configManager = new FlinkConfigManager(conf);
+
+        assertDoesNotThrow(
+                () ->
+                        new FlinkResourceContextFactory(
+                                configManager,
+                                TestUtils.createTestMetricGroup(new 
Configuration()),
+                                null));
+    }
+}

Reply via email to