camel-k icon indicating copy to clipboard operation
camel-k copied to clipboard

Knative dependencies are added when profile is activated

Open squakez opened this issue 1 year ago • 2 comments

I am not sure if this is some regression that has slipped in in the past or it was how the original feature was designed. The fact is that I noticed that when we have the Knative resource installed, any Integration (even a simple one which does not require any Knative stuff) add all the integrations and related server is started. See this timer-2-log:

[1] 2024-02-07 13:30:33,706 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 3.2.3
[1] 2024-02-07 13:30:33,709 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
[1] 2024-02-07 13:30:33,711 INFO  [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 4.0.2 is starting
[1] 2024-02-07 13:30:33,746 INFO  [org.apa.cam.k.sup.SourcesSupport] (main) Loading routes from: SourceDefinition{name='camel-k-embedded-flow', language='yaml', type='source', location='file:/etc/camel/sources/camel-k-embedded-flow.yaml', }
[1] 2024-02-07 13:30:33,947 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) is starting
[1] 2024-02-07 13:30:33,958 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Routes startup (started:1)
[1] 2024-02-07 13:30:33,958 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main)     Started route1 (timer://yaml)
[1] 2024-02-07 13:30:33,959 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Apache Camel 4.0.2 (camel-1) started in 11ms (build:0ms init:0ms start:11ms)
[1] 2024-02-07 13:30:34,066 INFO  [io.quarkus] (main) camel-k-integration 2.2.0 on JVM (powered by Quarkus 3.2.9.Final) started in 1.806s. Listening on: http://0.0.0.0:8080
[1] 2024-02-07 13:30:34,067 INFO  [io.quarkus] (main) Profile prod activated. 
[1] 2024-02-07 13:30:34,067 INFO  [io.quarkus] (main) Installed features: [camel-bean, camel-cloudevents, camel-core, camel-k-core, camel-k-runtime, camel-knative, camel-kubernetes, camel-timer, camel-yaml-dsl, cdi, kubernetes-client, smallrye-context-propagation, vertx]

The Integration dependency has really all the knative profile dependencies:

    dependencies:
    - camel:core
    - camel:timer
    - mvn:org.apache.camel.k:camel-k-knative-impl
    - mvn:org.apache.camel.k:camel-k-runtime
    - mvn:org.apache.camel.quarkus:camel-quarkus-knative
    - mvn:org.apache.camel.quarkus:camel-quarkus-yaml-dsl

I have the feeling this is not correct unless any Knative feature is really used by the route.

squakez avatar Feb 07 '24 13:02 squakez

@lburgazzoli wdyt? Is this really a regression or was the feature designed in this way for any reason?

squakez avatar Feb 07 '24 13:02 squakez

The knative trait is enabled=true when in profile=knative, then the init trait adds all dependencies from the knative capability. I can't remember the reason why it's enabled by default.

claudio4j avatar Feb 07 '24 14:02 claudio4j

WDYT to not set the the knative trait when the profile is knative ? Leaving it at the user discretion to enable it. As it adds the knative dependencies to any integration.

claudio4j avatar Mar 21 '24 11:03 claudio4j

I remember that a few years ago, the logic was to load the knative producer or consumer extensions depending on the presence of a knative consumer/producer endpoint or in case of the trait was explicitly enabled, I don't remember if some basic bits were also added by default depending on the profile.

In my opinion, it would be better to add the dependencies only if really needed.

lburgazzoli avatar Mar 21 '24 13:03 lburgazzoli

I will work to enable knative trait only if there is any knative endpoint in the route.

claudio4j avatar Mar 22 '24 08:03 claudio4j

Fixed in main branch, to be released in Camel K 2.3. The knative capability is only enabled when there is a knative endpoint in the route.

claudio4j avatar Mar 25 '24 17:03 claudio4j