Skip to content

Commit 9f10e32

Browse files
authored
Fix sample stopping after 1 minute. (#204)
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 3a87c96 commit 9f10e32

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

samples/spring-boot-auto-config/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<groupId>io.javaoperatorsdk</groupId>
1919
<artifactId>operator-framework-spring-boot-starter</artifactId>
2020
</dependency>
21+
<!-- without this, the app exits after 1 minute -->
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
2126
<dependency>
2227
<groupId>io.javaoperatorsdk</groupId>
2328
<artifactId>operator-framework-spring-boot-starter-samples-common</artifactId>

starter/src/main/java/io/javaoperatorsdk/operator/springboot/starter/OperatorHealthIndicator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.javaoperatorsdk.operator.springboot.starter;
22

3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
35
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
46
import org.springframework.boot.actuate.health.Health;
57
import org.springframework.stereotype.Component;
@@ -12,6 +14,8 @@ public class OperatorHealthIndicator extends AbstractHealthIndicator {
1214

1315
private final Operator operator;
1416

17+
private final static Logger log = LoggerFactory.getLogger(OperatorHealthIndicator.class);
18+
1519
public OperatorHealthIndicator(final Operator operator) {
1620
super("OperatorSDK health check failed");
1721
Assert.notNull(operator, "OperatorSDK Operator not initialized");
@@ -21,6 +25,7 @@ public OperatorHealthIndicator(final Operator operator) {
2125
@Override
2226
protected void doHealthCheck(Health.Builder builder) {
2327
final var runtimeInfo = operator.getRuntimeInfo();
28+
log.debug("Executing health check for {}", runtimeInfo);
2429
if (runtimeInfo.isStarted()) {
2530
final boolean[] healthy = {true};
2631
runtimeInfo.getRegisteredControllers().forEach(rc -> {
@@ -33,12 +38,14 @@ protected void doHealthCheck(Health.Builder builder) {
3338
builder.withDetail(name, "unhealthy: " + String.join(", ", unhealthy.keySet()));
3439
}
3540
});
41+
log.debug("Healthy: {}", healthy[0]);
3642
if (healthy[0]) {
3743
builder.up();
3844
} else {
3945
builder.down();
4046
}
4147
} else {
48+
log.debug("Healthy: unknown");
4249
builder.unknown();
4350
}
4451
}

0 commit comments

Comments
 (0)