apache / camel-k

Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers
https://camel.apache.org/camel-k
Apache License 2.0
864 stars 345 forks source link

Unable to use Processor in Kamelet, unable to get logs either #3937

Closed tarilabs closed 1 year ago

tarilabs commented 1 year ago

Hi, if this is not the correct place to report this kind of issues, kindly point me in the right direction (even chats).

TL;DR: as part of a Maven-based project, I have some data transformation method which I want to use and define in my Kamelet in camel-k. So far I've tested with a Processor which prints out a property (start even smaller in scope), but both Kamelet and KameletBinding fail during build, or trying our a simple Integration flow with the same processor fail locally too. My main issue is that beyond a generic exit status 1 I don't get much. What can I do, please?

What I've tried so far.

(propedeutic step) using flow with normal Camel

First, my dummy Processor is defined here. I define a very trivial flow:

- beans:
  - name: myp
    type: org.drools.yard.kdtable.KdtableProcessor
- from:
    uri: "timer:yaml"
    parameters:
      period: "5000"
    steps:
      - setBody:
          constant: "Hello Camel K from yaml"
      - process:
          ref: myp
      - transform:
          simple: "${body.toUpperCase()}"
      - to: "log:info"

If I try locally with camel (even before trying with camel-k in the picture) locally it works as I would expect, the property which happens to be defined in local application.properties is picked up in this case - or if I delete the .properties file, empty.

image

Attempt using Kamelet and Kamelet binding

I would have expected for a Kamelet to be able to incorporate the Processor/Bean without too much issues as described here. Unfortunately it does not work, but most importantly I'm not able to figure out what is the issue.

Example kamelet mmk.kamelet.yaml file:

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: mmk
  labels:
    camel.apache.org/kamelet.type: "action"
spec:
  definition:
    title: "mmk"
    description: prova
    properties:
      milliseconds:
        title: Milliseconds
        description: The number of milliseconds of delay
        type: integer
        example: 1000
      yard.kdtable:
        title: prova
        description: prova
        type: object
  dependencies:
  - "camel:core"
  - "camel:kamelet"
  - "github:kiegroup/yard/kamelet"
  template:
    beans:
      - name: myp
        type: org.drools.yard.kdtable.KdtableProcessor
    from:
      uri: "kamelet:source"
      steps:
      - process:
          ref: myp
      - to: "log:info"

Please notice supplied github:kiegroup/yard/kamelet which is the correct branch, per Camel doc.

example kamelet binding timer-source-binding.yaml file:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: timer-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: timer-source
    properties:
      message: hello world
      period: 5000
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      yard.kdtable: my asd value in KameletBinding

as I apply both files on K8s (minikube) everything seems to kick-start, but then the build fails.

image (46)

I have tried to apply the SOP as described in the Camel doc here. Unfortunately is not very helpful:

$ kubectl get builds.camel.apache.org -o json \
> | jq -r '.items[]
> | select(.status.phase == "Error")
> | "-n \(.metadata.namespace) builds.camel.apache.org/\(.metadata.name)"' \
> | xargs -L1 kubectl get -o jsonpath='{.metadata.namespace}{"/"}{.metadata.name}{"\nError: "}{.status.error}{"\n"}'
default/kit-ceee81ifluhc7399ij5g
Error: failure while building project: : exit status 1
default/kit-ceeeiaafluhc7399ij90
Error: failure while building project: : exit status 1

attempt to use Integration flow

As suggested in the Camel doc for troubleshooting, I've tried to redefine the flow as an Integration from the step1 above, so I just added the modeline for the same, resulting in:

# camel-k: language=yaml dependency=github:kiegroup/yard/kamelet

- beans:
  - name: myp
    type: org.drools.yard.kdtable.KdtableProcessor
- from:
    uri: "timer:yaml"
    parameters:
      period: "5000"
    steps:
      - setBody:
          constant: "Hello Camel K from yaml"
      - process:
          ref: myp
      - transform:
          simple: "${body.toUpperCase()}"
      - to: "log:info"

but I'm met with analogous error:

$ kamel local run test.yaml --verbose
Modeline options have been loaded from source files
Full command: kamel local run test.yaml --verbose --dependency=github:kiegroup/yard/kamelet 
Command "run" is deprecated, consider using Camel JBang instead (https://camel.apache.org/manual/camel-jbang.html)
Error: failed to compute transitive dependencies: failure while building project: [ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.14.0.Final:build (default) on project camel-k-integration: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors: exit status 1

exit status 1

How can I understand what's the problem that causing exit status 1, please? So far, I'm not able to fetch the "internal logs" which might give any clue of the issue, and I haven't found the case for this in the Camel manual (hope given enough proofs I've actually read it in the above report! πŸ˜… ) Thank you in advance,

squakez commented 1 year ago

Starting from the end of the issue: the generic exit status 1 error report should be fixed by #3779 already in version 1.10.0. If there is still some case where the error is not exposed, please, report it with a reproducer and we will evaluate how to fix.

About the rest of the problem, we'll be having a look asap, thanks for reporting.

tarilabs commented 1 year ago

If there is still some case where the error is not exposed, please, report it with a reproducer and we will evaluate how to fix.

@squakez I am on 1.11.0 I would expect above https://github.com/apache/camel-k/issues/3937#issue-1503165235 should contain all steps to reproduce, the code (of the Processor) is available on github in the indicated branch? πŸ€”

squakez commented 1 year ago

Yes, I was more thinking in any future similar problem that may happen. The issue description is very complete and we will try to reproduce it as soon as we can.

tarilabs commented 1 year ago

On suggestion by @lucamolteni (πŸ™ thanks Luca) I'm using kubectl logs -f camel-k-operator-844bdcc954-bncpt (logs of the Camel-k Operator Pod) and at least now I can inspect the logs of the quarkus build in some more details, I'm working following this lead now.

squakez commented 1 year ago

My gut feeling is that Camel K cannot retrieve the github:kiegroup/yard/kamelet dependency directly. You may try to forcefully declare it via Jitpack (https://camel.apache.org/camel-k/1.11.x/configuration/dependencies.html#dependencies-kind-jitpack) to see if that simply fixes the problem.

squakez commented 1 year ago

I've managed to reproduce the issue, so, according to the log, this is failing because it cannot find the org.drools.yard.kdtable.KdtableComponentConfigurer class. I've looked into the repo, but I am not able to find it, can you please verify if that class is really available once the dependency is compiled?

tarilabs commented 1 year ago

You may try to forcefully declare it via Jitpack (https://camel.apache.org/camel-k/1.11.x/configuration/dependencies.html#dependencies-kind-jitpack) to see if that simply fixes the problem.

Isn't this what I'm already doing with specifying github:kiegroup/yard/kamelet ? πŸ€”

Anyhow yes, now working by removign all things Component-related, and just keeping for Processor-related, as anyway I understand Kamelet requires for Component to be published on maven central (for catalog purposes)

squakez commented 1 year ago

Isn't this what I'm already doing with specifying github:kiegroup/yard/kamelet ? thinking

Yes, but there could be a bug. I am not entirely sure that jitpack dependency declared in the Kamelet is later "passed" to the Integration.

squakez commented 1 year ago

I've run a simple Jitpack application in order to see if the dependency really compiles, and it seems it does not:

kamel run /tmp/test/Jitpack.java -d github:squakez/samplejp/v1.0 -d github:kiegroup/yard/kamelet --dev

The first Jitpack sample compiles but the second doesn't with the same error reported when used in Kamelet. I think the problem is there indeed and you may simply debug it by compiling it in a simpler Integration to see if it works.

Also it seems that the Integration does include the dependency as declared in the Kamelet btw.

lburgazzoli commented 1 year ago

my 2c: I think github:kiegroup/yard/kamelet does not resolve to an actual dependency (in fact it is a multi module project) , however github:squakez/samplejp/v1.0 does which may explain the behavior

tarilabs commented 1 year ago

I'm trying with another branch only Processor and there seems to be some cache issues inside the Operator

{"level":"info","ts":1671532906.9534621,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"info","ts":1671532906.9535449,"logger":"camel-k.maven.build","msg":"BUILD FAILURE"}
{"level":"info","ts":1671532906.95374,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"info","ts":1671532906.958559,"logger":"camel-k.maven.build","msg":"Total time:  1.830 s (Wall Clock)"}
{"level":"info","ts":1671532906.962005,"logger":"camel-k.maven.build","msg":"Finished at: 2022-12-20T10:41:46Z"}
{"level":"info","ts":1671532906.9620912,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"error","ts":1671532906.965436,"logger":"camel-k.maven.build","msg":"Failed to execute goal on project camel-k-integration: Could not resolve dependencies for project org.apache.camel.k.integration:camel-k-integration:jar:1.11.0: com.github.kiegroup:yard:jar:camelkprocessor was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]","stacktrace":"github.com/apache/camel-k/pkg/util/log.Logger.Error\n\tgithub.com/apache/camel-k/pkg/util/log/log.go:75\ngithub.com/apache/camel-k/pkg/util/maven.normalizeLog\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:83\ngithub.com/apache/camel-k/pkg/util/maven.mavenLogHandler\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:54\ngithub.com/apache/camel-k/pkg/util.scan\n\tgithub.com/apache/camel-k/pkg/util/command.go:77\ngithub.com/apache/camel-k/pkg/util.RunAndLog.func1\n\tgithub.com/apache/camel-k/pkg/util/command.go:56\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\tgolang.org/x/sync@v0.1.0/errgroup/errgroup.go:75"}

@lburgazzoli does the github: reference MUST be a simple maven project, and MUST NOT be a maven multi-module project, please? πŸ€”

(asking as Jitpack would publish the "parent" as an aggregator, but looking to understand if this use-case is supported by camel-k, please)

squakez commented 1 year ago

@lburgazzoli good point. @tarilabs I'm having a look at the Jitpack mutimodules here: https://jitpack.io/docs/BUILDING/#multi-module-projects not sure how we support this use case, but you can try using a module in the while.

tarilabs commented 1 year ago

I'm having a look at the Jitpack mutimodules here: https://jitpack.io/docs/BUILDING/#multi-module-projects not sure how we support this use case ...

@squakez okay, but please keep me posted about it,

(asking as Jitpack would publish the "parent" as an aggregator, but looking to understand if this use-case is supported by camel-k, please)

as if this use-case is supported by Camel-K, or not, would influence decision on the project I'm working on, please. Thank you in advance for a supported yes/no statement, eventually.

squakez commented 1 year ago

After some debugging I can tell that the Jitpack multimodules works out of the box in Camel K. However, there is a little detail, that is, we should use -SNAPSHOT when using code in branch (tag is used for fixed version, see more details in this example).

It turns out that, for example, the following integration works correctly:

kamel run Jitpack.java -d github:squakez/samplejp/multimodules-SNAPSHOT --dev

However, when testing your application, I still can see it fails with the same error, even using -d github:kiegroup/yard/kamelet-SNAPSHOT. I have tried to jitpack locally and it seems it manages to compile correctly, downloading locally the expected dependencies. At this stage I wonder if the error is related to some Quarkus removal of classes that are later required at build time.

squakez commented 1 year ago

By the way, in which dependency is this class expected? org.drools.yard.kdtable.KdtableComponentConfigurer maybe just adding that dependency to the integration is enough.

tarilabs commented 1 year ago

By the way, in which dependency is this class expected? org.drools.yard.kdtable.KdtableComponentConfigurer maybe just adding that dependency to the integration is enough.

That is allegedly a class produced by the camel plugin in the module yard-kdtable. It seems Quarkus is ignoring that as part of the build (inside camel-k)

tarilabs commented 1 year ago

Is there a way to elide the Maven m2 cache inside the Camel-K Operator, please? I'm facing some This failure was cached in the local repository and resolution is not reattempted until the update interval of jitpack.io-cegqqjqfluhc73dibivg has elapsed or updates are forced ... errors

tarilabs commented 1 year ago

update: I believe the problem might be related to the fact one of the module in the multi-module is another Quarkus application, as the Camel-K Operator is now failing with

{"level":"info","ts":1671541114.4692822,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"info","ts":1671541114.4694455,"logger":"camel-k.maven.build","msg":"BUILD FAILURE"}
{"level":"info","ts":1671541114.4706187,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"info","ts":1671541114.4731157,"logger":"camel-k.maven.build","msg":"Total time:  01:13 min (Wall Clock)"}
{"level":"info","ts":1671541114.4731894,"logger":"camel-k.maven.build","msg":"Finished at: 2022-12-20T12:58:34Z"}
{"level":"info","ts":1671541114.473202,"logger":"camel-k.maven.build","msg":"------------------------------------------------------------------------"}
{"level":"error","ts":1671541114.477396,"logger":"camel-k.maven.build","msg":"Failed to execute goal io.quarkus:quarkus-maven-plugin:2.14.0.Final:build (default) on project camel-k-integration: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors","stacktrace":"github.com/apache/camel-k/pkg/util/log.Logger.Error\n\tgithub.com/apache/camel-k/pkg/util/log/log.go:75\ngithub.com/apache/camel-k/pkg/util/maven.normalizeLog\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:83\ngithub.com/apache/camel-k/pkg/util/maven.mavenLogHandler\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:54\ngithub.com/apache/camel-k/pkg/util.scan\n\tgithub.com/apache/camel-k/pkg/util/command.go:77\ngithub.com/apache/camel-k/pkg/util.RunAndLog.func1\n\tgithub.com/apache/camel-k/pkg/util/command.go:56\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\tgolang.org/x/sync@v0.1.0/errgroup/errgroup.go:75"}
{"level":"error","ts":1671541114.477517,"logger":"camel-k.maven.build","msg":"\t[error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.NoSuchMethodError: 'io.fabric8.kubernetes.api.model.rbac.PolicyRuleFluent io.fabric8.kubernetes.api.model.rbac.PolicyRuleBuilder.addNewApiGroup(java.lang.String)'","stacktrace":"github.com/apache/camel-k/pkg/util/log.Logger.Error\n\tgithub.com/apache/camel-k/pkg/util/log/log.go:75\ngithub.com/apache/camel-k/pkg/util/maven.normalizeLog\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:83\ngithub.com/apache/camel-k/pkg/util/maven.mavenLogHandler\n\tgithub.com/apache/camel-k/pkg/util/maven/maven_log.go:54\ngithub.com/apache/camel-k/pkg/util.scan\n\tgithub.com/apache/camel-k/pkg/util/command.go:77\ngithub.com/apache/camel-k/pkg/util.RunAndLog.func1\n\tgithub.com/apache/camel-k/pkg/util/command.go:56\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\tgolang.org/x/sync@v0.1.0/errgroup/errgroup.go:75"}

So while I've tried Kamelet having:

  dependencies:
  - "camel:core"
  - "camel:kamelet"
  - "github:kiegroup/yard/camelk-SNAPSHOT"

per earlier suggestion, this might be problematic as the jitpack aggregator would make another quarkus app a (transitive dependency). Just a wild guess 🀷

tarilabs commented 1 year ago

So, an update. I've mixed @squakez and @lburgazzoli suggestions. Local kamel works, Kamelet does not, ~same flow per Camel doc suggestions.

local flow (works)

this

# camel-k: language=yaml dependency=github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT

- beans:
  - name: myp
    type: org.drools.yard.kdtable.KdtableProcessor
- from:
    uri: "timer:yaml"
    parameters:
      period: "5000"
    steps:
      - setBody:
          constant: "Hello Camel K from yaml"
      - process:
          ref: myp
      - transform:
          simple: "${body.toUpperCase()}"
      - to: "log:info"

works:

$ kamel local run test.yaml --verbose
Modeline options have been loaded from source files
Full command: kamel local run test.yaml --verbose --dependency=github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT 
Command "run" is deprecated, consider using Camel JBang instead (https://camel.apache.org/manual/camel-jbang.html)
Executing: java -cp test.yaml:
...
{"timestamp":"2022-12-20T14:05:39.855+01:00","sequence":175,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus","level":"INFO","message":"Profile prod activated. ","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:39.855+01:00","sequence":176,"loggerClassName":"org.jboss.logging.Logger","loggerName":"io.quarkus","level":"INFO","message":"Installed features: [camel-bean, camel-core, camel-k-core, camel-k-runtime, camel-kubernetes, camel-log, camel-timer, camel-yaml-dsl, cdi, kubernetes-client, security]","threadName":"main","threadId":1,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:40.861+01:00","sequence":177,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"org.drools.yard.kdtable.KdtableProcessor","level":"INFO","message":"for prop key kdtable value Optional.empty","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:40.889+01:00","sequence":178,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"info","level":"INFO","message":"Exchange[ExchangePattern: InOnly, BodyType: String, Body: HELLO CAMEL K FROM YAML]","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:45.855+01:00","sequence":179,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"org.drools.yard.kdtable.KdtableProcessor","level":"INFO","message":"for prop key kdtable value Optional.empty","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:45.857+01:00","sequence":180,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"info","level":"INFO","message":"Exchange[ExchangePattern: InOnly, BodyType: String, Body: HELLO CAMEL K FROM YAML]","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:50.86+01:00","sequence":181,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"org.drools.yard.kdtable.KdtableProcessor","level":"INFO","message":"for prop key kdtable value Optional.empty","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
{"timestamp":"2022-12-20T14:05:50.861+01:00","sequence":182,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"info","level":"INFO","message":"Exchange[ExchangePattern: InOnly, BodyType: String, Body: HELLO CAMEL K FROM YAML]","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":31044}
...

~same flow in kamelet (not working 🀷 )

but this kamelet:

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: mmk
  labels:
    camel.apache.org/kamelet.type: "action"
spec:
  definition:
    title: "mmk"
    description: prova
    properties:
      milliseconds:
        title: Milliseconds
        description: The number of milliseconds of delay
        type: integer
        example: 1000
      yard.kdtable:
        title: prova
        description: prova
        type: object
  dependencies:
  - "camel:core"
  - "camel:kamelet"
  - "github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT"
  template:
    beans:
      - name: myp
        type: org.drools.yard.kdtable.KdtableProcessor
    from:
      uri: "kamelet:source"
      steps:
      - process:
          ref: myp
      - to: "log:info"

with this binding:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: timer-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: timer-source
    properties:
      message: hello world
      period: 5000
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      yard.kdtable: my asd value in KameletBinding

gives me:

2022-12-20 13:04:00,540 INFO  [org.apa.cam.k.Runtime] (main) Apache Camel K Runtime 1.16.0
2022-12-20 13:04:00,567 INFO  [org.apa.cam.qua.cor.CamelBootstrapRecorder] (main) Bootstrap runtime: org.apache.camel.quarkus.main.CamelMainRuntime
2022-12-20 13:04:00,569 INFO  [org.apa.cam.mai.MainSupport] (main) Apache Camel (Main) 3.19.0 is starting
2022-12-20 13:04:00,617 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='camel-k-embedded-flow', language='yaml', type='source', location='file:/etc/camel/sources/camel-k-embedded-flow.yaml', }
2022-12-20 13:04:00,659 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='mmk', language='yaml', type='source', location='file:/etc/camel/sources/mmk.yaml', }
2022-12-20 13:04:00,661 INFO  [org.apa.cam.k.lis.SourcesConfigurer] (main) Loading routes from: SourceDefinition{name='timer-source', language='yaml', type='source', location='file:/etc/camel/sources/timer-source.yaml', }
2022-12-20 13:04:00,883 WARN  [org.apa.cam.imp.eng.AbstractCamelContext] (main) Lifecycle strategy org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler@6e4c0d8c vetoed initializing CamelContext (camel-1) due to: Failure creating route from template: mmk
2022-12-20 13:04:00,883 INFO  [org.apa.cam.imp.eng.AbstractCamelContext] (main) CamelContext (camel-1) vetoed to not initialize due to: Failure creating route from template: mmk
2022-12-20 13:04:00,884 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (main) Failed to start application: org.apache.camel.RuntimeCamelException: org.apache.camel.VetoCamelContextStartException: Failure creating route from template: mmk
 at org.apache.camel.RuntimeCamelException.wrapRuntimeException(RuntimeCamelException.java:66)
 at org.apache.camel.support.service.BaseService.doFail(BaseService.java:413)
 at org.apache.camel.impl.engine.AbstractCamelContext.doFail(AbstractCamelContext.java:3613)
 at org.apache.camel.support.service.BaseService.fail(BaseService.java:342)
 at org.apache.camel.impl.engine.AbstractCamelContext.failOnStartup(AbstractCamelContext.java:5302)
 at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2683)
 at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
 at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2690)
 at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)
 at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94)
 at org.apache.camel.support.service.BaseService.start(BaseService.java:119)
 at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140)
 at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
 at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
 at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source)
 at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source)
 at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
 at io.quarkus.runtime.Application.start(Application.java:101)
 at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:43)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:123)
 at io.quarkus.runner.GeneratedMain.main(Unknown Source)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:61)
 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:32)
Caused by: org.apache.camel.VetoCamelContextStartException: Failure creating route from template: mmk
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.onContextInitialized(KameletComponent.java:433)
 at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:3009)
 at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:174)
 at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
 at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2671)
 ... 23 more
Caused by: org.apache.camel.component.kamelet.KameletNotFoundException: Kamelet with id mmk not found in locations: classpath:/kamelets
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.createRouteForEndpoint(KameletComponent.java:421)
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.onContextInitialized(KameletComponent.java:430)
 ... 27 more
Caused by: java.lang.IllegalArgumentException: Route template local bean: myp has invalid type syntax: org.drools.yard.kdtable.KdtableProcessor. To refer to a class then prefix the value with #class such as: #class:fullyQualifiedClassName
 at org.apache.camel.impl.DefaultModel.bind(DefaultModel.java:650)
 at org.apache.camel.impl.DefaultModel.addTemplateBeans(DefaultModel.java:488)
 at org.apache.camel.impl.DefaultModel.addRouteFromTemplate(DefaultModel.java:448)
 at org.apache.camel.impl.DefaultModel.addRouteFromTemplate(DefaultModel.java:350)
 at org.apache.camel.impl.DefaultCamelContext.addRouteFromTemplate(DefaultCamelContext.java:458)
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.createRouteForEndpoint(KameletComponent.java:409)
 ... 28 more
2022-12-20 13:04:00,919 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.IllegalArgumentException: Route template local bean: myp has invalid type syntax: org.drools.yard.kdtable.KdtableProcessor. To refer to a class then prefix the value with #class such as: #class:fullyQualifiedClassName
 at org.apache.camel.impl.DefaultModel.bind(DefaultModel.java:650)
 at org.apache.camel.impl.DefaultModel.addTemplateBeans(DefaultModel.java:488)
 at org.apache.camel.impl.DefaultModel.addRouteFromTemplate(DefaultModel.java:448)
 at org.apache.camel.impl.DefaultModel.addRouteFromTemplate(DefaultModel.java:350)
 at org.apache.camel.impl.DefaultCamelContext.addRouteFromTemplate(DefaultCamelContext.java:458)
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.createRouteForEndpoint(KameletComponent.java:409)
 at org.apache.camel.component.kamelet.KameletComponent$LifecycleHandler.onContextInitialized(KameletComponent.java:430)
 at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:3009)
 at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:174)
 at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
 at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2671)
 at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
 at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2690)
 at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)
 at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94)
 at org.apache.camel.support.service.BaseService.start(BaseService.java:119)
 at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140)
 at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
 at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
 at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source)
 at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source)
 at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
 at io.quarkus.runtime.Application.start(Application.java:101)
 at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:110)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:43)
 at io.quarkus.runtime.Quarkus.run(Quarkus.java:123)
 at io.quarkus.runner.GeneratedMain.main(Unknown Source)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:61)
 at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:32)

In the integration Pod.

Suggestions, please? πŸ€”

tarilabs commented 1 year ago

I've tried using the #class:<fqcn> instead. The property works with kamel local but not with Kamelet.

flow with local

# camel-k: language=yaml dependency=github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT

- from:
    uri: "timer:yaml"
    parameters:
      period: "5000"
    steps:
      - setBody:
          constant: "Hello Camel K from yaml"
      - process:
          ref: '#class:org.drools.yard.kdtable.KdtableProcessor'
      - transform:
          simple: "${body.toUpperCase()}"
      - to: "log:info"

works as expected:

$ kamel local run test.yaml --verbose -p kdtable=testviakamelcli
Modeline options have been loaded from source files
Full command: kamel local run test.yaml --verbose -p kdtable=testviakamelcli --dependency=github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT 
...
{"timestamp":"2022-12-20T14:33:39.078+01:00","sequence":183,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"org.drools.yard.kdtable.KdtableProcessor","level":"INFO","message":"for prop key kdtable value Optional[testviakamelcli]","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":34051}
{"timestamp":"2022-12-20T14:33:39.079+01:00","sequence":184,"loggerClassName":"org.slf4j.impl.Slf4jLogger","loggerName":"info","level":"INFO","message":"Exchange[ExchangePattern: InOnly, BodyType: String, Body: HELLO CAMEL K FROM YAML]","threadName":"Camel (camel-1) thread #1 - timer://yaml","threadId":17,"mdc":{},"ndc":"","hostName":"mmortari1-mac","processName":"io.quarkus.bootstrap.runner.QuarkusEntryPoint","processId":34051}
...

(the value testviakamelcli is logged by the log in the route)

flow with kamelet (not working 🀷 )

apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: mmk
  labels:
    camel.apache.org/kamelet.type: "action"
spec:
  definition:
    title: "mmk"
    description: prova
    properties:
      kdtable:
        title: prova
        description: prova
        type: object
  dependencies:
  - "camel:core"
  - "camel:kamelet"
  - "github:kiegroup.yard/yard-kdtable/camelk-SNAPSHOT"
  template:
    from:
      uri: "kamelet:source"
      steps:
      - process:
          ref: '#class:org.drools.yard.kdtable.KdtableProcessor'
      - to: "log:info"

and:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: timer-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: timer-source
    properties:
      message: hello world
      period: 5000
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      kdtable: my asd value in KameletBinding

in the integration pod log

...
2022-12-20 13:31:22,318 INFO  [org.dro.yar.kdt.KdtableProcessor] (Camel (camel-1) thread #1 - timer://tick) for prop key kdtable value Optional.empty
2022-12-20 13:31:22,319 INFO  [info] (Camel (camel-1) thread #1 - timer://tick) Exchange[ExchangePattern: InOnly, BodyType: String, Body: hello world]
...

Screenshot 2022-12-20 at 14 35 28

Suggestions, please? πŸ€”

squakez commented 1 year ago

The problem is that in your Kamelet definition you're not passing your kdtable property anywhere. If you want to replicate what you are doing in your local call (via -p kdtable=testviakamelcli), then you have to provide such property to the KameletBinding as an application.properties. You can do that via annotations (like trait.camel.apache.org/camel.properties: "kdtable=testviakamelcli").

tarilabs commented 1 year ago

@squakez how is this from my kamelet binding?

...
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      kdtable: my asd value in KameletBinding (1)

(1) not enough, please?

My goal would be to set this property (for the Processor, which takes it from the Kamelet def, which should take it from the binding).

How can I do that property configuration from inside a kameletbinding yaml file, please?

squakez commented 1 year ago

@squakez how is this from my kamelet binding?

...
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      kdtable: my asd value in KameletBinding (1)

(1) not enough, please?

The problem is that such a property is not going to be included in the application properties, or, better said, it is going to end up in an application properties as something like kamelet.mmk.kdtable=value. According to your local execution, you need it to be a plain property.

My goal would be to set this property (for the Processor, which takes it from the Kamelet def, which should take it from the binding).

How can I do that property configuration from inside a kameletbinding yaml file, please?

You can use the annotation I've provided in the previous comment as explained in https://camel.apache.org/camel-k/1.11.x/kamelets/kamelets-user.html#_trait_via_annotations

tarilabs commented 1 year ago

@squakez pardon me, but I would need some better guidance. My goal would be to have something like this, "inline" in a kamelet binding yaml file.

i.e.: I want somewhere to have:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: timer-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: timer-source
    properties:
      message: hello world
      period: 5000
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: mmk
    properties:
      kdtable:
       type: DecisionTable
       inputs: ['Violation.type', 'Violation.Actual Speed - Violation.Speed Limit']
       outputComponents: ['Amount', 'Points']
       rules:
        - ['="speed"', '[10..30)', 500, 3]
        - ['="speed"', '>= 30', 1000, 7]
        - ['="parking"', '-', 100, 1]
        - ['="driving under the influence"', '-', 1000, 5]

or similar in a KameletBinding file.

What's the best way to:

which would fetch the kdtable configuration (regardless of the actual name of the Kamelet), please?

squakez commented 1 year ago

I think this is going a bit OT from the original issue as it is about how to design a Kamelet. The design guidelines are exposed in Kamelet developer guide. If still need support after reading that, please, better log a new request with a new question so we can have a cleaner discussion from scratch.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale due to 90 days of inactivity. It will be closed if no further activity occurs within 15 days. If you think that’s incorrect or the issue should never stale, please simply write any comment. Thanks for your contributions!

tarilabs commented 1 year ago

About stale: the root cause is synthesised as https://github.com/apache/camel-k/issues/3981

Closing this one.