2424import org .apache .camel .karavan .KaravanCache ;
2525import org .apache .camel .karavan .KaravanConstants ;
2626import org .apache .camel .karavan .model .CamelStatusRequest ;
27+ import org .apache .camel .karavan .service .ConfigService ;
2728import org .eclipse .microprofile .config .inject .ConfigProperty ;
2829import 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