Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAI-681: Integrate TrustyService with Quarkus DevServices services #1759

Merged
merged 8 commits into from
Jan 13, 2022

Conversation

manstis
Copy link
Contributor

@manstis manstis commented Nov 29, 2021

See https://issues.redhat.com/browse/FAI-681

Part of an ensemble:

These PRs contain the changes I've had to implement to have the following running:-

  • A kogito application running on localhost:8080
  • This kogito application starting a Docker container for a service it needs TrustyService.
  • This kogito application connecting with and using Quarkus' DevServices Redpanda (Kafka) instance.
  • TrustyService connecting with and using Quarkus' DevServices Redpanda (Kafka) instance.
  • TrustyService connecting with and using Quarkus' DevServices PostgreSQL instance.

You can run https://github.com/kiegroup/kogito-examples/pull/1032 to see this work.

Then enter mvn compile quarkus:dev and wait a bit for things to start.

You can make a model evaluation request:

curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"Bribe": 0,"Client": {"age": 0,"existing payments": 0,"salary": 0},"Loan": {"duration": 0,"installment": 0},"SupremeDirector": "yes"}' http://localhost:8080/LoanEligibility

You can also check things are getting processed elsewhere:

Get PostgreSQL's IP address

  • Run docker network prune (it makes a step below easier to explain!)
  • Run docker ps and make a note of the image NAME for postgres e.g. gifted_nobel.
  • Run docker network ls and make a note of the NETWORK ID for a bridge (that does not have the name bridge) e.g. c41e6358dddb
  • Run docker network inspect c41e6358dddb (NETWORK ID from the previous step) and look at the Containers section.
  • Find the entry with the Name matching that PostgreSQL name you found earlier.
  • Make a note of the IPv4Address e.g. 192.168.64.3.

Run a PostgreSQL client

  • docker run -it --rm --network XXX jbergknoff/postgresql-client postgresql://quarkus:quarkus@YYY:5432/default
  • Where XXX is the NETWORK ID above, e.g. c41e6358dddb
  • Where YYY is the IP address above, e.g. 192.168.64.3

Inspect stuff*

  • In the PostgreSQL client terminal enter select count(*) from kogito_data_cache;

Known issue
You will see in the Quarkus logs something like:-

2021-11-29 12:12:59,359 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 2021-11-29 12:12:59,350 ERROR [org.kie.kog.tru.ser.com.mes.BaseEventConsumer] (ForkJoinPool.commonPool-worker-5) Something unexpected happened during the processing of an Event. The event is discarded.: java.lang.IllegalArgumentException: A model with ID XXX is already present in the storage.
2021-11-29 12:12:59,360 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.TrustyServiceImpl.storeModel(TrustyServiceImpl.java:187)
2021-11-29 12:12:59,360 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.TrustyServiceImpl_ClientProxy.storeModel(TrustyServiceImpl_ClientProxy.zig:683)
2021-11-29 12:12:59,361 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.messaging.incoming.ModelEventConsumer.internalHandleCloudEvent(ModelEventConsumer.java:78)
2021-11-29 12:12:59,361 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.messaging.incoming.ModelEventConsumer.internalHandleCloudEvent(ModelEventConsumer.java:41)
2021-11-29 12:12:59,362 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.messaging.BaseEventConsumer.handleCloudEvent(BaseEventConsumer.java:84)
2021-11-29 12:12:59,362 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.Optional.ifPresent(Optional.java:183)
2021-11-29 12:12:59,362 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.messaging.BaseEventConsumer.handleMessage(BaseEventConsumer.java:58)
2021-11-29 12:12:59,363 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at org.kie.kogito.trusty.service.common.messaging.incoming.ModelEventConsumer.lambda$handleMessage$0(ModelEventConsumer.java:60)
2021-11-29 12:12:59,363 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
2021-11-29 12:12:59,364 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728)
2021-11-29 12:12:59,364 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:2902021-11-29 12:12:59,364 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
2021-11-29 12:12:59,365 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
2021-11-29 12:12:59,365 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
2021-11-29 12:12:59,366 INFO  [org.kie.kog.tra.dec.qua.dev.TrustyServiceInMemoryContainer] (docker-java-stream--1324434781) STDOUT: 	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

This is caused by "hot reload" support. When the DMN model is deployed kogito triggers a hot restart of Quarkus. The problem is that a ModelEvent was fired when Quarkus started the first time and again following the restart. The PostgreSQL container is not stopped, re-started and cleared for the hot reload... a new JIRA can be created.


Many thanks for submitting your Pull Request ❤️!

Please make sure that your PR meets the following requirements:

  • You have read the contributors guide
  • Your code is properly formatted according to this configuration
  • Pull Request title is properly formatted: KOGITO-XYZ Subject
  • Pull Request title contains the target branch if not targeting main: [0.9.x] KOGITO-XYZ Subject
  • Pull Request contains link to the JIRA issue
  • Pull Request contains link to any dependent or related Pull Request
  • Pull Request contains description of the issue
  • Pull Request does not include fixes for issues other than the main ticket
How to replicate CI configuration locally?

Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.

How to retest this PR or trigger a specific build:
  • Run all builds
    Please add comment: Jenkins retest this

  • Run (or rerun) specific test(s)
    Please add comment: Jenkins (re)run [kogito-runtimes|optaplanner|kogito-apps|kogito-examples|optaplanner-quickstarts|optaweb-employee-rostering|optaweb-vehicle-routing] tests

  • Quarkus LTS checks
    Please add comment: Jenkins run LTS

  • Run (or rerun) LTS specific test(s)
    Please add comment: Jenkins (re)run [kogito-runtimes|optaplanner|kogito-apps|kogito-examples|optaplanner-quickstarts|optaweb-employee-rostering|optaweb-vehicle-routing] LTS

  • Native checks
    Please add comment: Jenkins run native

  • Run (or rerun) native specific test(s)
    Please add comment: Jenkins (re)run [kogito-runtimes|optaplanner|kogito-apps|kogito-examples|optaplanner-quickstarts|optaweb-employee-rostering|optaweb-vehicle-routing] native

  • Full Kogito testing (with cloud images and operator BDD testing)
    Please add comment: Jenkins run BDD
    This check should be used only if a big change is done as it takes time to run, need resources and one full BDD tests check can be done at a time ...

@manstis
Copy link
Contributor Author

manstis commented Nov 29, 2021

@r00ta @danielezonca Trusty's tracing-addon can now launch TrustyService and integrate with Quarkus's Kafka and PostgreSQL instances (created and launched by Quarkus' DevServices). I am working on the final stage of adding the Trusty UI into Quarkus' DevUI (@kelvah has refactored our UI to fit, I should just need to complete the integration).

@manstis manstis removed the request for review from cristianonicolai November 29, 2021 12:31
@manstis
Copy link
Contributor Author

manstis commented Nov 29, 2021

@cristianonicolai FYI really.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) optaplanner check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) kogito-runtimes check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) optaweb-employee-rostering check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) optaplanner-quickstarts check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) kogito-apps check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) optaweb-vehicle-routing check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 29, 2021

The (build) kogito-examples check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) optaweb-vehicle-routing check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) kogito-runtimes check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) kogito-examples check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) optaweb-employee-rostering check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) optaplanner check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) kogito-apps check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Nov 30, 2021

The (build) optaplanner-quickstarts check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) kogito-runtimes check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) kogito-examples check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) optaplanner-quickstarts check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) kogito-apps check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) optaplanner check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) optaweb-employee-rostering check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) optaweb-vehicle-routing check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Dec 2, 2021

The (build) kogito-runtimes check has failed. Please check the logs.

@kie-ci
Copy link
Contributor

kie-ci commented Jan 10, 2022

The (build) kogito-apps check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 11, 2022

Jenkins retest this

@kie-ci
Copy link
Contributor

kie-ci commented Jan 11, 2022

The (build) kogito-apps check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 11, 2022

Jenkins run kogito-apps tests

@manstis
Copy link
Contributor Author

manstis commented Jan 11, 2022

@danielezonca @r00ta @jiripetrlik Let's try to get these PRs merged....

The circular dependency issue is not unique for this extension. The processes extension also relies upon the publication of a kogito image to quay.io; that is not built until kogito-apps and not published to quay.io until kogito-images. Can we not address the wider issue of this circular design as a new JIRA rather hijack this PR for an existing issue?

Versioning of the quay.io image to use for Trusty Service (PostgreSQL). I have extracted the version to application.properties and the pom.xml as proposed. Maven updates application.properties with the property from the pom.xml when building... This is fine, however what should I do for updating the property in the pom.xml? It needs to be "the last non-latest version published to quay.io". (Un)surprisingly there is no property in our Maven setup for this!! IIRC @r00ta you run a home-grown automated update for a similar property elsewhere. Is that my best option? Can you provide a link to your utility?

The use of Quarkus datasources and jdbc-postgres dependencies in this addon. Their presence tricks Quarkus into starting a PostgreSQL Docker container for PostgreSQL that we then connect to from Trusty Service and therefore, their inclusion is not entirely desirable. I only need their -deployment parts but Quarkus will not allow them without their equivalent -runtime cousins. Looking at the content of all the JARs there is very little to them and I wonder if, at least for now, their inclusion is the lessor of two evils: dependencies that arguably should not be there vs duplicating the function and code ourselves. I'm happy to consider the alternative approach and remove their inclusion.... but can we do as a new JIRA?

WDYT?

Copy link
Contributor

@danielezonca danielezonca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 👍

@danielezonca
Copy link
Contributor

@manstis
I agree I think the current solution is in line with the rest of the platform.
We can do followup tickets but we should be ready to merge.

Well done 👍

Copy link
Contributor

@r00ta r00ta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@manstis
Copy link
Contributor Author

manstis commented Jan 12, 2022

Copy link
Contributor

@jiripetrlik jiripetrlik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree to merge this and try to discuss about circular dependencies in the future. However, I'm still not convinced about swallowing exceptions as was mentioned in one of my previous comments. But it is probably not a big issue.

@kie-ci
Copy link
Contributor

kie-ci commented Jan 12, 2022

The (build) kogito-examples check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 12, 2022

Jenkins run kogito-examples tests

@kie-ci
Copy link
Contributor

kie-ci commented Jan 12, 2022

The (build) kogito-apps check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 12, 2022

Jenkins run kogito-apps tests

@kie-ci
Copy link
Contributor

kie-ci commented Jan 12, 2022

The (build) kogito-runtimes check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 12, 2022

Jenkins run kogito-runtimes tests

@kie-ci
Copy link
Contributor

kie-ci commented Jan 12, 2022

The (build) kogito-examples check has failed. Please check the logs.

@manstis
Copy link
Contributor Author

manstis commented Jan 12, 2022

Jenkins run kogito-examples tests

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug B 2 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 42 Code Smells

0.0% 0.0% Coverage
8.0% 8.0% Duplication

@manstis manstis merged commit 6602d45 into apache:main Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants