KaotoIO/kaoto-backend

[BUG] Multiple Integrations generated cannot be executed by Camel Runtime

apupier opened this issue · 5 comments

Describe the bug

when creating several Camel Route of kind Integration, the generated file cannot be executed

To Reproduce
Steps to reproduce the behavior:

  1. Create 2 New route of kind Integration
  2. Try to execute it
    --> it fails because it is using several documents in the yaml and Camel Rntime doesn't support it: https://issues.apache.org/jira/browse/CAMEL-19534

Expected behavior

Generates a format supported by the runtime.
so instead of something like:

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: route-3571
spec:
  flows:
  - from:
      uri: timer:demo
      steps:
      - log:
          message: demo
---
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: route-2623
spec:
  flows:
  - from:
      uri: timer:second
      steps:
      - log:
          message: second

generates something like:

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  name: route-3571
spec:
  flows:
  - from:
      uri: timer:demo
      steps:
      - log:
          message: demo
  - from:
      uri: timer:second
      steps:
      - log:
          message: second

Logs

error at runtime:

org.apache.camel.RuntimeCamelException: Error pre-parsing resource: file:testKameletBinding.camel.yaml
        at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader.preParseRoute(YamlRoutesBuilderLoader.java:863) ~[camel-yaml-dsl-3.20.6.jar:3.20.6]
        at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:104) ~[camel-base-engine-3.20.6.jar:3.20.6]
        at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:88) ~[camel-base-engine-3.20.6.jar:3.20.6]
        at org.apache.camel.impl.engine.DefaultRoutesLoader.updateRoutes(DefaultRoutesLoader.java:195) ~[camel-base-engine-3.20.6.jar:3.20.6]
        at org.apache.camel.support.RouteWatcherReloadStrategy.onRouteReload(RouteWatcherReloadStrategy.java:265) ~[camel-support-3.20.6.jar:3.20.6]
        at org.apache.camel.support.RouteWatcherReloadStrategy.lambda$doStart$1(RouteWatcherReloadStrategy.java:150) ~[camel-support-3.20.6.jar:3.20.6]
        at org.apache.camel.support.FileWatcherResourceReloadStrategy$WatchFileChangesTask.run(FileWatcherResourceReloadStrategy.java:305) ~[camel-support-3.20.6.jar:3.20.6]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: org.snakeyaml.engine.v2.exceptions.ComposerException: expected a single document in the stream
 in file:testKameletBinding.camel.yaml, line 1, column 1:
    apiVersion: camel.apache.org/v1
    ^
but found another document
 in file:testKameletBinding.camel.yaml, line 12, column 1:
    ---
    ^

        at org.snakeyaml.engine.v2.composer.Composer.getSingleNode(Composer.java:134) ~[snakeyaml-engine-2.3.jar:?]
        at org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader.preParseRoute(YamlRoutesBuilderLoader.java:860) ~[camel-yaml-dsl-3.20.6.jar:3.20.6]
        ... 11 more

Environment (please complete the following information):

red.ht/kaoto-snapshots

Additional context

How did you run it? since this is already k8s CRD, you can kubectl apply -f integration.kind.yaml and I though it would understand multiple CRDs?

Anyway, Kaoto won't yet support multiple CRDs in a same file with --- separator, it's just there because of bugs like KaotoIO/kaoto-ui#2055

How did you run it?

camel run <filename>

From the UI side, we can no longer create multiple CRDs: KaotoIO/kaoto-ui#2064
From the backend side, there was a missing functionality to embed routes inside of a single Integration CRD: #734

It's still possible to paste or open a file containing multiple CRDs.

Are more changes needed for this issue since we're not planning to support multiple CRDs yet?

This issue is about the generated Integration file when using UI with multiple routes. It was generating with multiple Yaml documents in the same file.

it is not about supporting multiple Yaml documents in the same file (which is not supported by Runtime anyway).

Based on other issues fixed, I suppose that now it generates a file with a single Yaml Document which is a CRD of an integration that contains severla routes and that this file can be executed by tthe runtime. So it seems fixed.