Skip to content

Commit 6904725

Browse files
committed
Merge branch 'quick-shutdown' into 'release/4.2'
Ensure operator can shut down quickly See merge request weblogic-cloud/weblogic-kubernetes-operator!4804
2 parents bc3053b + 0e93fc8 commit 6904725

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

operator/src/main/java/oracle/kubernetes/operator/BaseMain.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator;
@@ -249,6 +249,7 @@ void waitForDeath() {
249249

250250
acquireShutdownSignal();
251251

252+
wrappedExecutorService.shutdown();
252253
stopAllWatchers();
253254
}
254255

operator/src/main/java/oracle/kubernetes/operator/work/Engine.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.work;
@@ -48,7 +48,12 @@ public Engine() {
4848
* @return executor service
4949
*/
5050
public static ScheduledExecutorService wrappedExecutorService(Container container) {
51-
ScheduledThreadPoolExecutor threadPool = new ScheduledThreadPoolExecutor(DEFAULT_THREAD_COUNT);
51+
ScheduledThreadPoolExecutor threadPool = new ScheduledThreadPoolExecutor(
52+
DEFAULT_THREAD_COUNT, r -> {
53+
Thread t = Executors.defaultThreadFactory().newThread(r);
54+
t.setDaemon(true);
55+
return t;
56+
});
5257
threadPool.setRemoveOnCancelPolicy(true);
5358
return wrap(container, new VirtualScheduledExectuorService(threadPool));
5459
}

operator/src/test/java/oracle/kubernetes/operator/work/FiberTestSupport.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.work;
@@ -284,6 +284,11 @@ int getNumItemsRun() {
284284
return numItemsRun;
285285
}
286286

287+
@Override
288+
public void shutdown() {
289+
// no-op
290+
}
291+
287292
@Override
288293
@Nonnull
289294
public ScheduledFuture<?> schedule(

0 commit comments

Comments
 (0)