Skip to content

Commit 8292ed6

Browse files
committed
Scheduler fixes
1 parent 2577491 commit 8292ed6

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

karavan-app/src/main/java/org/apache/camel/karavan/scheduler/CamelStatusScheduler.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.camel.karavan.KaravanCache;
2525
import org.apache.camel.karavan.KaravanConstants;
2626
import org.apache.camel.karavan.model.CamelStatusRequest;
27+
import org.apache.camel.karavan.service.ConfigService;
2728
import org.eclipse.microprofile.config.inject.ConfigProperty;
2829
import org.jboss.logging.Logger;
2930

@@ -51,14 +52,25 @@ public class CamelStatusScheduler {
5152
@Scheduled(every = "{karavan.camel.status.interval}", concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
5253
public void collectCamelStatuses() {
5354
LOGGER.debug("Collect Camel Statuses");
54-
karavanCache.getPodContainerStatuses(environment).stream()
55-
.filter(cs -> Objects.equals(cs.getLabels().get(LABEL_KUBERNETES_RUNTIME), CAMEL_PREFIX))
56-
.filter(cs -> Objects.equals(cs.getCamelRuntime(), KaravanConstants.CamelRuntime.CAMEL_MAIN.getValue()))
57-
.forEach(cs -> {
58-
CamelStatusRequest csr = new CamelStatusRequest(cs.getProjectId(), cs.getContainerName());
59-
eventBus.publish(CMD_COLLECT_CAMEL_STATUS,
60-
JsonObject.mapFrom(Map.of("containerStatus", cs, "camelStatusRequest", csr))
61-
);
62-
});
55+
if (ConfigService.inKubernetes()) {
56+
karavanCache.getPodContainerStatuses(environment).stream()
57+
.filter(cs -> Objects.equals(cs.getLabels().get(LABEL_KUBERNETES_RUNTIME), CAMEL_PREFIX))
58+
.filter(cs -> Objects.equals(cs.getCamelRuntime(), KaravanConstants.CamelRuntime.CAMEL_MAIN.getValue()))
59+
.forEach(cs -> {
60+
CamelStatusRequest csr = new CamelStatusRequest(cs.getProjectId(), cs.getContainerName());
61+
eventBus.publish(CMD_COLLECT_CAMEL_STATUS,
62+
JsonObject.mapFrom(Map.of("containerStatus", cs, "camelStatusRequest", csr))
63+
);
64+
});
65+
} else {
66+
karavanCache.getPodContainerStatuses(environment).stream()
67+
.filter(cs -> Objects.equals(cs.getCamelRuntime(), KaravanConstants.CamelRuntime.CAMEL_MAIN.getValue()))
68+
.forEach(cs -> {
69+
CamelStatusRequest csr = new CamelStatusRequest(cs.getProjectId(), cs.getContainerName());
70+
eventBus.publish(CMD_COLLECT_CAMEL_STATUS,
71+
JsonObject.mapFrom(Map.of("containerStatus", cs, "camelStatusRequest", csr))
72+
);
73+
});
74+
}
6375
}
6476
}

0 commit comments

Comments
 (0)