Skip to content

Commit e9570e7

Browse files
committed
Add readiness probe
1 parent b831a67 commit e9570e7

File tree

8 files changed

+58
-13
lines changed

8 files changed

+58
-13
lines changed

docs/charts/index.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
apiVersion: v1
22
entries:
33
weblogic-operator:
4-
- created: 2019-04-04T14:48:45.073688-04:00
4+
- created: 2019-04-19T18:49:45.158227-04:00
55
description: Helm chart for configuring the WebLogic operator.
6-
digest: c505f999cd43fdf9cd7a52d8e2db47a96e22e68f5116e47fb6dafee0bb31fa0e
6+
digest: 83193bfdea8a9643428bc85cd154584bd80742d0f8c92b502039e939fd2884c4
77
name: weblogic-operator
88
urls:
99
- https://oracle.github.io/weblogic-kubernetes-operator/charts/weblogic-operator-2.2.tgz
1010
version: "2.2"
11-
- created: 2019-04-04T14:48:45.071125-04:00
11+
- created: 2019-04-19T18:49:45.156092-04:00
1212
description: Helm chart for configuring the WebLogic operator.
1313
digest: 391e23c0969ada5f0cd2a088ddc6f11f237f57521801ed3925db2149a8437a0d
1414
name: weblogic-operator
1515
urls:
1616
- https://oracle.github.io/weblogic-kubernetes-operator/charts/weblogic-operator-2.1.tgz
1717
version: "2.1"
18-
- created: 2019-04-04T14:48:45.06358-04:00
18+
- created: 2019-04-19T18:49:45.153902-04:00
1919
description: Helm chart for configuring the WebLogic operator.
2020
digest: 298acda78ab73db6b7ba6f2752311bfa40c65874e03fb196b70976192211c1a5
2121
name: weblogic-operator
2222
urls:
2323
- https://oracle.github.io/weblogic-kubernetes-operator/charts/weblogic-operator-2.0.1.tgz
2424
version: 2.0.1
25-
generated: 2019-04-04T14:48:45.054609-04:00
25+
generated: 2019-04-19T18:49:45.149858-04:00

docs/charts/weblogic-operator-2.2.tgz

14 Bytes
Binary file not shown.

kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ spec:
6666
command:
6767
- "bash"
6868
- "/operator/livenessProbe.sh"
69-
initialDelaySeconds: 120
69+
initialDelaySeconds: 20
7070
periodSeconds: 5
71+
readinessProbe:
72+
exec:
73+
command:
74+
- "bash"
75+
- "/operator/readinessProbe.sh"
76+
initialDelaySeconds: 2
77+
periodSeconds: 10
7178
{{- if .elkIntegrationEnabled }}
7279
- name: "logstash"
7380
image: {{ .logStashImage | quote }}

kubernetes/samples/scripts/common/domain-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# This is an example of how to define a Domain resource.
55
#
6+
apiVersion: "weblogic.oracle/v4"
67
kind: Domain
78
metadata:
89
name: %DOMAIN_UID%

kubernetes/samples/scripts/create-weblogic-domain/manually-create-domain/domain.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This is an example of how to define a Domain resource. Please read through the comments which explain
55
# what updates are needed.
66
#
7+
apiVersion: "weblogic.oracle/v4"
78
kind: Domain
89
metadata:
910
# Update this with the `domainUID` of your domain:

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ private static void completeBegin() {
223223
.scheduleWithFixedDelay(
224224
recheckDomains(), recheckInterval, recheckInterval, TimeUnit.SECONDS);
225225

226-
// Wait until all other initialization is done before starting liveness thread
226+
// Wait until all other initialization is done before marking ready and
227+
// starting liveness thread
227228

228-
// start liveness thread
229-
startLivenessThread();
229+
// mark ready and start liveness thread
230+
markReadyAndStartLivenessThread();
230231

231232
} catch (Throwable e) {
232233
LOGGER.warning(MessageKeys.EXCEPTION, e);
@@ -431,10 +432,16 @@ private static void stopRestServer() {
431432
RestServer.destroy();
432433
}
433434

434-
private static void startLivenessThread() {
435-
LOGGER.info(MessageKeys.STARTING_LIVENESS_THREAD);
436-
// every five seconds we need to update the last modified time on the liveness file
437-
wrappedExecutorService.scheduleWithFixedDelay(new OperatorLiveness(), 5, 5, TimeUnit.SECONDS);
435+
private static void markReadyAndStartLivenessThread() {
436+
try {
437+
OperatorReady.create();
438+
439+
LOGGER.info(MessageKeys.STARTING_LIVENESS_THREAD);
440+
// every five seconds we need to update the last modified time on the liveness file
441+
wrappedExecutorService.scheduleWithFixedDelay(new OperatorLiveness(), 5, 5, TimeUnit.SECONDS);
442+
} catch (IOException io) {
443+
LOGGER.severe(MessageKeys.EXCEPTION, io);
444+
}
438445
}
439446

440447
private static final Semaphore shutdownSignal = new Semaphore(0);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at
3+
// http://oss.oracle.com/licenses/upl.
4+
5+
package oracle.kubernetes.operator;
6+
7+
import java.io.File;
8+
import java.io.IOException;
9+
10+
/** This task creates the "readiness" indicator so that Kubernetes knows the Operator is ready */
11+
public class OperatorReady {
12+
13+
private static final File readinessFile = new File("/operator/.ready");
14+
15+
public static void create() throws IOException {
16+
if (!readinessFile.exists()) {
17+
readinessFile.createNewFile();
18+
}
19+
}
20+
}

src/scripts/readinessProbe.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
5+
if [ ! -f /operator/.ready ]; then
6+
exit 1;
7+
fi
8+
9+
exit 0

0 commit comments

Comments
 (0)