mertdotcc opened a new issue, #4126: URL: https://github.com/apache/camel-k/issues/4126
Hey everyone, I have two very similar integrations: IntegrationOne.java: ``` package com.myCompany.integrations; // camel-k: language=java // camel-k: name=integration-one import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; public class IntegrationOne extends RouteBuilder { @Override public void configure() throws Exception { onException(Exception.class) .handled(true) .setHeader("CamelHttpResponseCode").constant("400") .setBody().simple("resource:file:/etc/camel/resources/sample-error-response.json") .log(LoggingLevel.ERROR, "exception", "${exception}").routeId("exception"); from("direct://integrationOne").routeId("integrationOne") .log(LoggingLevel.INFO, "log-1", "headers: ${headers}; body: ${body}") .setBody().constant("resource:file:/etc/camel/resources/integration_one.json"); } } ``` I use the following command to run `IntegrationOne`: ``` kamel run \ --resource file:./resources/sample-error-response.json \ --resource file:./mappingresources/integration_one.json \ --trait container.enabled=true \ --trait container.request-cpu="250m" \ --trait container.request-memory="256Mi" \ --trait container.limit-cpu="500m" \ --trait container.limit-memory="512Mi" \ --trait container.port=8443 \ --trait health.enabled=true \ --trait health.liveness-probe-enabled=true \ --trait health.liveness-scheme="HTTP" \ --trait health.liveness-initial-delay=0 \ --trait health.liveness-timeout=10 \ --trait health.liveness-period=15 \ --trait health.liveness-success-threshold=1 \ --trait health.liveness-failure-threshold=3 \ --trait health.readiness-probe-enabled=true \ --trait health.readiness-scheme="HTTP" \ --trait health.readiness-initial-delay=0 \ --trait health.readiness-timeout=10 \ --trait health.readiness-period=15 \ --trait health.readiness-success-threshold=1 \ --trait health.readiness-failure-threshold=3 \ --trait knative-service.enabled=true \ --trait knative-service.autoscaling-class="kpa.autoscaling.knative.dev" \ --trait knative-service.autoscaling-metric="rps" \ --trait knative-service.autoscaling-target=100 \ --trait knative-service.min-scale=0 \ --trait knative-service.max-scale=20 \ --trait quarkus.enabled=true \ --trait quarkus.package-type=fast-jar \ --trait quarkus.package-type=native \ IntegrationOne.java ``` I have a second integration, that is very similar to my first integration. Almost identical. Except the last line of code in the DSL. Notice that they are using a different JSON file there as a body. IntegrationTwo.java: ``` package com.myCompany.integrations; // camel-k: language=java // camel-k: name=integration-two import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; public class IntegrationTwo extends RouteBuilder { @Override public void configure() throws Exception { onException(Exception.class) .handled(true) .setHeader("CamelHttpResponseCode").constant("400") .setBody().simple("resource:file:/etc/camel/resources/sample-error-response.json") .log(LoggingLevel.ERROR, "exception", "${exception}").routeId("exception"); from("direct://integrationTwo").routeId("integrationTwo") .log(LoggingLevel.INFO, "log-1", "headers: ${headers}; body: ${body}") .setBody().constant("resource:file:/etc/camel/resources/integration_two.json"); } } ``` I use the following command to run `IntegrationTwo`: ``` kamel run \ --resource file:./resources/sample-error-response.json \ --resource file:./mappingresources/integration_two.json \ --trait container.enabled=true \ --trait container.request-cpu="250m" \ --trait container.request-memory="256Mi" \ --trait container.limit-cpu="500m" \ --trait container.limit-memory="512Mi" \ --trait container.port=8443 \ --trait health.enabled=true \ --trait health.liveness-probe-enabled=true \ --trait health.liveness-scheme="HTTP" \ --trait health.liveness-initial-delay=0 \ --trait health.liveness-timeout=10 \ --trait health.liveness-period=15 \ --trait health.liveness-success-threshold=1 \ --trait health.liveness-failure-threshold=3 \ --trait health.readiness-probe-enabled=true \ --trait health.readiness-scheme="HTTP" \ --trait health.readiness-initial-delay=0 \ --trait health.readiness-timeout=10 \ --trait health.readiness-period=15 \ --trait health.readiness-success-threshold=1 \ --trait health.readiness-failure-threshold=3 \ --trait knative-service.enabled=true \ --trait knative-service.autoscaling-class="kpa.autoscaling.knative.dev" \ --trait knative-service.autoscaling-metric="rps" \ --trait knative-service.autoscaling-target=100 \ --trait knative-service.min-scale=0 \ --trait knative-service.max-scale=20 \ --trait quarkus.enabled=true \ --trait quarkus.package-type=fast-jar \ --trait quarkus.package-type=native \ IntegrationTwo.java ``` The problem is that these two integrations want to use the same image and I can't seem to control this process and force a new image build for the second integration. To be more specific: I first deploy my `IntegrationOne`, the image is built with no problem, and my pod is running as expected. Then when I run my `kamel run` command for my `IntegrationTwo` and I inspect my `Integrations` and `IntegrationKits` using `k9s`, I notice that the `Phase` of my `IntegrationTwo` switches from `Initializing` to `Running` automatically. It doesn't enter the `Build Running` phase. When I inspect, I realized that the `IntegrationTwo` is using the same `camel-k-kit` as my `IntegrationOne`. Well, this is obviously an issue as the `camel-k-kit` that was built for my `IntegrationOne` doesn't contain the `resource` `integration_two.json` and thus I get the following error in my `IntegrationTwo` pod: ``` 2023-03-12 22:36:53,063 ERROR [io.qua.run.Application] (main) Failed to start application (with profile [prod]): java.io.FileNotFoundException: /etc/camel/resources/integration_two.json does not exists org.apache.camel.impl.engine.DefaultResourceResolvers$FileResolver$1.getInputStream(DefaultResourceResolvers.java:77) org.apache.camel.support.ResourceHelper.resolveResourceAsInputStream(ResourceHelper.java:134) org.apache.camel.support.ResourceHelper.resolveMandatoryResourceAsInputStream(ResourceHelper.java:112) org.apache.camel.support.ScriptHelper.resolveOptionalExternalScript(ScriptHelper.java:96) org.apache.camel.support.ScriptHelper.resolveOptionalExternalScript(ScriptHelper.java:46) org.apache.camel.reifier.language.ExpressionReifier.createExpression(ExpressionReifier.java:174) org.apache.camel.reifier.AbstractReifier.createExpression(AbstractReifier.java:119) org.apache.camel.reifier.SetBodyReifier.createProcessor(SetBodyReifier.java:34) org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:857) org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:598) org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:211) org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:75) org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:937) org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:800) org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:3008) org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:174) org.apache.camel.support.service.BaseService.init(BaseService.java:83) org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2679) org.apache.camel.support.service.BaseService.start(BaseService.java:111) org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2698) org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262) org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94) org.apache.camel.support.service.BaseService.start(BaseService.java:119) org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140) org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49) org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45) io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source) io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source) io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) io.quarkus.runtime.Application.start(Application.java:101) io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:108) io.quarkus.runtime.Quarkus.run(Quarkus.java:71) io.quarkus.runtime.Quarkus.run(Quarkus.java:44) io.quarkus.runtime.Quarkus.run(Quarkus.java:124) io.quarkus.runner.GeneratedMain.main(Unknown Source) ``` This whole problem is caused by Camel-K being super efficient and resourceful when it comes to building new images as it tries to re-use them as much as possible. 🙂 But for situations like these, can't we have a new flag in our `kamel run` command, something like `--forceImageBuild` and have it bypass all of Camel-K's efficient image re-use logic and force build a new image? I am open to any questions/suggestions and I can provide more details/error logs if needed. Many thanks in advance! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org