1
1
package io .javaoperatorsdk .operator .springboot .starter ;
2
2
3
+ import org .slf4j .Logger ;
4
+ import org .slf4j .LoggerFactory ;
3
5
import org .springframework .boot .actuate .health .AbstractHealthIndicator ;
4
6
import org .springframework .boot .actuate .health .Health ;
5
7
import org .springframework .stereotype .Component ;
@@ -12,6 +14,8 @@ public class OperatorHealthIndicator extends AbstractHealthIndicator {
12
14
13
15
private final Operator operator ;
14
16
17
+ private final static Logger log = LoggerFactory .getLogger (OperatorHealthIndicator .class );
18
+
15
19
public OperatorHealthIndicator (final Operator operator ) {
16
20
super ("OperatorSDK health check failed" );
17
21
Assert .notNull (operator , "OperatorSDK Operator not initialized" );
@@ -21,6 +25,7 @@ public OperatorHealthIndicator(final Operator operator) {
21
25
@ Override
22
26
protected void doHealthCheck (Health .Builder builder ) {
23
27
final var runtimeInfo = operator .getRuntimeInfo ();
28
+ log .debug ("Executing health check for {}" , runtimeInfo );
24
29
if (runtimeInfo .isStarted ()) {
25
30
final boolean [] healthy = {true };
26
31
runtimeInfo .getRegisteredControllers ().forEach (rc -> {
@@ -33,12 +38,14 @@ protected void doHealthCheck(Health.Builder builder) {
33
38
builder .withDetail (name , "unhealthy: " + String .join (", " , unhealthy .keySet ()));
34
39
}
35
40
});
41
+ log .debug ("Healthy: {}" , healthy [0 ]);
36
42
if (healthy [0 ]) {
37
43
builder .up ();
38
44
} else {
39
45
builder .down ();
40
46
}
41
47
} else {
48
+ log .debug ("Healthy: unknown" );
42
49
builder .unknown ();
43
50
}
44
51
}
0 commit comments