-
Notifications
You must be signed in to change notification settings - Fork 115
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
Quarkus SQL-based RAG recipe #826
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jan Martiska <[email protected]>
87a7416
to
00c8516
Compare
Very cool thanks @jmartisk ! |
Waiting on @jmartisk or @jeffmaury |
Is anything required from me at this point? I assume this is waiting for more reviewers' eyes. From my PoV this is ready atm. |
# should be replaced with a mechanism to declare that the application | ||
# container depends on the database container, once something like that is | ||
# supported... | ||
CMD echo "sleeping for 10 seconds..."; sleep 10; /usr/local/s2i/run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recipes should following the cloud native pattern so should implement retry if the targeted service is not available or handle propertly failures so is this required ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, Quarkus itself does not support retries like this (it relies on it being restarted if the database isn't ready yet) and just refuses to boot if it can't connect :( I know this is a terrible solution, but I don't have any better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is it possible to declare somewhere (in ai-lab.yaml
) that the Quarkus pod should be restarted until it boots properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because the design has been made so that there is no synchronisation between the containers that are started. There is no way to delay the connection to the database ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yrodiere could you advise if there is a way to let Quarkus boot even when the database is not available yet, and let Hibernate execute its database generation strategy more lazily? I checked the configuration properties and nothing came to my mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no built-in way to let db generation execute lazily -- among other reasons because that could be very dangerous (you don't want that to happen twice).
Also, booting with an offline DB is technically not supported yet (it's WIP: quarkusio/quarkus#43396), but if you're not using anything exotic it'll probably work anyway.
The way to go would be to disable DB generation/validation, and execute it explicitly through custom code relying on org.hibernate.SessionFactory#getSchemaManager
.
The problem will be to detect when you should initialize the DB... Maybe Agroal provides a "first connection" event that could be used for that, I don't know. That's probably something that should be filed as a new feature, as a follow-up to 43396 -- but it's not limited to Hibernate ORM, you'd have the same problem with Flyway schema management (which, by the way, is what you should be using in prod).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, in any case, none of this looks like something we want to do in this recipe that should be kept as simple as possible. IMO, AI lab should provide a way to declare dependencies between pods. Without it, I have no better idea than a dumb sleep command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, or maybe, add some piece of a shell script to wait for the database port to be open before calling /usr/local/s2i/run
?? Would that be ok?
To test this out, add this to
$HOME/.local/share/containers/podman-desktop/extensions-storage/redhat.ai-lab/user-catalog.json
:One thing I'm not sure about is how to properly declare that the Quarkus app pod has to wait for the PostgreSQL pod to start. I've added a 10-second sleep (see the
Containerfile
) to the startup now, but... that's a very nasty and probably unreliable workaround.CC @geoand, @maxandersen, @cescoffier