Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

[BUG] Sending an END step when it should be middle #586

Closed
Delawen opened this issue Mar 28, 2023 · 7 comments · Fixed by #594
Closed

[BUG] Sending an END step when it should be middle #586

Delawen opened this issue Mar 28, 2023 · 7 comments · Fixed by #594
Assignees
Labels
bug Something isn't working

Comments

@Delawen
Copy link
Collaborator

Delawen commented Mar 28, 2023

Fix the backend side of kaoto-archive/kaoto-ui#1562

@igarashitm
Copy link
Contributor

So the fix would be to change this to action - https://github.com/KaotoIO/camel-component-metadata/blob/main/stop.camel-component.yaml#L10

But is it really right? as far as I can see from the official doc, it stops routing no matter how the branch is deep, so the canvas shouldn't connect anything after stop isn't it?
https://camel.apache.org/components/3.20.x/eips/stop-eip.html

@igarashitm
Copy link
Contributor

Verified

Route

- from:
    uri: timer:null
    steps:
    - choice:
        when:
        - simple: true
          steps:
          - log:
              message: stopping
          - stop: {}
    - log:
        message: not stopping

output

[tomo@p1 tmp]$ camel run stop.yaml 
2023-03-28 13:13:42.075  INFO 118557 --- [           main] org.apache.camel.main.MainSupport   : Apache Camel (JBang) 3.20.2 is starting
2023-03-28 13:13:42.262  INFO 118557 --- [           main] org.apache.camel.main.MainSupport   : Using Java 19.0.2 with PID 118557. Started by tomo in /home/tomo/Downloads/tmp
2023-03-28 13:13:42.270  INFO 118557 --- [           main] mel.cli.connector.LocalCliConnector : Camel CLI enabled (local)
2023-03-28 13:13:42.766  INFO 118557 --- [           main] el.impl.engine.AbstractCamelContext : Apache Camel 3.20.2 (stop) is starting
2023-03-28 13:13:42.869  INFO 118557 --- [           main] el.impl.engine.AbstractCamelContext : Routes startup (started:1)
2023-03-28 13:13:42.869  INFO 118557 --- [           main] el.impl.engine.AbstractCamelContext :     Started route1 (timer://null)
2023-03-28 13:13:42.869  INFO 118557 --- [           main] el.impl.engine.AbstractCamelContext : Apache Camel 3.20.2 (stop) started in 268ms (build:66ms init:100ms start:102ms JVM-uptime:1s)
2023-03-28 13:13:43.863  INFO 118557 --- [ - timer://null] stop.yaml:8                         : stopping
2023-03-28 13:13:44.855  INFO 118557 --- [ - timer://null] stop.yaml:8                         : stopping

@igarashitm
Copy link
Contributor

Even more problematic is like this

- from:
    uri: timer:null
    steps:
    - choice:
        when:
        - simple: headers.country == 'UK'
          steps:
          - log:
              message: stopping
          - stop: {}
    - log:
        message: not stopping

where if headers.country is NOT UK, it goes to the log not stopping. Then, how the diagram should look like? In theory, we shouldn't connect anything after stop, but then where the log not stopping should connect? choice?

@igarashitm
Copy link
Contributor

igarashitm commented Mar 28, 2023

Aside stop, the URI log: in the branch is marked as END on backend YAML>JSON where it shouldn't.

Trying to fix, but not yet sure how. In order to use MIDDLE log step when it's in a branch, set end=false here
https://github.com/KaotoIO/kaoto-backend/blob/7a9d6c2406ff85a2049d89a129271388e5f8e58d/kamelet-support/src/main/java/io/kaoto/backend/model/deployment/kamelet/step/EIPStep.java#L95

And change this comparator, if end != true then use MIDDLE type of the step
https://github.com/KaotoIO/kaoto-backend/blob/7a9d6c2406ff85a2049d89a129271388e5f8e58d/kamelet-support/src/main/java/io/kaoto/backend/model/deployment/kamelet/step/UriFlowStep.java#L117-L144

Then 2 problems,

  1. no idea what this means - https://github.com/KaotoIO/kaoto-backend/blob/7a9d6c2406ff85a2049d89a129271388e5f8e58d/kamelet-support/src/main/java/io/kaoto/backend/model/deployment/kamelet/step/UriFlowStep.java#L124-L127
  2. Actually there're 3 log steps, no idea what's the difference between log-MIDDLE and log-action
Step{
  id='log-producer'
, name='log'
, uuid=null
, title=Log
, type=END
}
Step{
  id='log-MIDDLE'
, name='log'
, uuid=null
, title=Log
, type=MIDDLE
}
Step{
  id='log-action'
, name='log'
, uuid=null
, title=Log
, type=MIDDLE
}

@Delawen do you see how this is supposed to be?

@igarashitm
Copy link
Contributor

Seems to need a background knowledge - releasing

@igarashitm igarashitm removed their assignment Mar 29, 2023
@Delawen
Copy link
Collaborator Author

Delawen commented Mar 29, 2023

There is a log component (split into MIDDLE/action and END/producer) and an EIP component. That's because the step catalog distinguish between both. And that's why we order the components there to return always first the MIDDLE, but return an END if there is no MIDDLE available.

The

 //EIPs shouldn't go through this function 
 if (step.getKind().startsWith("EIP")) { 
     return 10000; 
 } 

means, as the comment said, that EIPs shouldn't arrive at that function. But just in case they arrive, put them at the end of the list of potential responses. If that's the only valid response, well, ok, something weird happened, just return the EIP.

@igarashitm
Copy link
Contributor

I'll double check, but it looks like the opposite happens, END type of log is always returned. Which of log-MIDDLE and log-action is used for when? and why EIP shouldn't arrive there? like if there's log component and log EIP, log component is at higher priority?

@igarashitm igarashitm self-assigned this Mar 29, 2023
Delawen pushed a commit that referenced this issue Mar 30, 2023
Fixes: #586

This also applies a workaround for kaoto-archive/kaoto-ui#1587, change the `stop` EIP to be `MIDDLE` type while it's actually an `END`. We need to get this back to be `END` once kaoto-archive/kaoto-ui#1587 is implemented
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants