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

Quarkus Liquibase MongoDB extension properties not used #25850

Closed
Dosexe opened this issue May 29, 2022 · 10 comments · Fixed by #26499
Closed

Quarkus Liquibase MongoDB extension properties not used #25850

Dosexe opened this issue May 29, 2022 · 10 comments · Fixed by #26499
Labels
Milestone

Comments

@Dosexe
Copy link

Dosexe commented May 29, 2022

Describe the bug

Quarkus Liquibase extension doesn't respect quarkus mongodb properties as it is expected.
Liquibase extension only uses 3 properties:

  • connection string,
  • username
  • password.

This can be checked in io.quarkus.liquibase.mongodb.LiquibaseMongodbFactory in createLiquibase method.
This will lead to an error on application startup if you are using quarkus properties for MongoDB configuration, for an example
quarkus.mongodb.credentials.auth-source or quarkus.mongodb.database instead of adding all this params to connection string.

Expected behavior

Quarkus mongodb properties are repsected by quarkus-liquibase-mongodb extension

Actual behavior

Application throws error on starup.

This error will showup if authSource and db not present in connString.

com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed)

This error will showup if authSource present in connString but no db specified.

java.lang.IllegalArgumentException: Database not specified in URL
	at liquibase.ext.mongodb.database.MongoConnection.open(MongoConnection.java:110)
	at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:32)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:214)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:176)
	at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
	at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:130)
	at io.quarkus.liquibase.mongodb.LiquibaseMongodbFactory.createLiquibase(LiquibaseMongodbFactory.java:42)
	at io.quarkus.liquibase.mongodb.LiquibaseMongodbFactory_959fd9b7b35a536942315a4e37b512f2717c8f52_Synthetic_ClientProxy.createLiquibase(Unknown Source)
	at io.quarkus.liquibase.mongodb.runtime.LiquibaseMongodbRecorder.doStartActions(LiquibaseMongodbRecorder.java:47)
	at io.quarkus.deployment.steps.LiquibaseMongodbProcessor$startLiquibase1869009359.deploy_0(Unknown Source)
	at io.quarkus.deployment.steps.LiquibaseMongodbProcessor$startLiquibase1869009359.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:103)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
	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.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
	at java.base/java.lang.Thread.run(Thread.java:829)

How to Reproduce?

Use quarkus mongodb settings and setup quarkus-liquibase-mongodb extension

quarkus:
  mongodb:
    tls: false
    connection-string: ${MONGODB_CON_STRING:mongodb://localhost:27017}
    database: customDB
    credentials:
      auth-source: ${MONGODB_AUTH_SOURCE}
      username: ${MONGODB_USERNAME}
      password: ${MONGODB_PASSWORD}
  liquibase-mongodb:
    migrate-at-start: true
    change-log: db/changelog.json

Output of uname -a or ver

Darwin Kernel Version 21.1.0

Output of java -version

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.4.2

Additional information

No response

@Dosexe Dosexe added the kind/bug Something isn't working label May 29, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented May 29, 2022

@NMichas
Copy link

NMichas commented Jun 30, 2022

Is this still an issue on 2.10.0?

My mongodb user doesn't have colmod permission and Liquibase fails to run. I tried setting quarkus.liquibase-mongodb.validate-on-migrate=false (as per https://forum.liquibase.org/t/what-is-the-role-of-the-user-to-acquire-a-lock-in-mongodb/5190) but seems to be ignored.

@geoand
Copy link
Contributor

geoand commented Jun 30, 2022

I'll have a look tomorrow and get back to you

@geoand
Copy link
Contributor

geoand commented Jul 1, 2022

@loicmathieu is this something you want to tackle?

@loicmathieu
Copy link
Contributor

@geoand I can have a look next week.

quarkus.liquibase-mongodb.validate-on-migrate=false should be honored, if not it's a bug.

For the other properties, we need to implement them, Liquibase MongoDB cannot use our Mongo client instance so we need to pass it the properties, it's not very convenient, that's why all properties are not supported. Maybe also we need to document it a little more.

@loicmathieu
Copy link
Contributor

@NMichas we honor quarkus.liquibase-mongodb.validate-on-migrate=false if it's not working as expected it's a liquibase MongoDB bug.

Note that for disabling liquibase migration you should use quarkus.liquibase-mongodb.migrate-at-start=false.

@loicmathieu
Copy link
Contributor

I had a look and the best I can do is to add the authSource inside the mongodb connection String.
I have a PR for this, not tested yet as it's not easy to test, if you can build my branch and test it it would help a lot.
https://github.com/quarkusio/quarkus/pull/26499/files

@mfaghloumi
Copy link

Is this still an issue on 2.10.0?

My mongodb user doesn't have colmod permission and Liquibase fails to run. I tried setting quarkus.liquibase-mongodb.validate-on-migrate=false (as per https://forum.liquibase.org/t/what-is-the-role-of-the-user-to-acquire-a-lock-in-mongodb/5190) but seems to be ignored.

The issue is still present on 2.13.2 on my side. @NMichas Did you find any workaround ?

@geoand I can have a look next week.

quarkus.liquibase-mongodb.validate-on-migrate=false should be honored, if not it's a bug.

Regarding this, it's not really a bug, disabling validation on migration is honored, but not the validation of the changeloglock collection for example. In order to disable those we need to configure liquibase to disable validators globally using the LiquibaseDatabase.

@NMichas
Copy link

NMichas commented Oct 14, 2022

@mfaghloumi nope, I couldn't make it work. For now in dev, I just gave dbAdmin to my user, but a proper solution is needed for when this project goes to prod.

FYI, I've used Bitnami's MongoDB Helm with this:
esthesis-iot_–esthesis-mongodb_values_yaml__esthesis-iot

@mfaghloumi
Copy link

@NMichas It's a bit more complex for me to have the collMod, and as you stated it it isn't an option for production.
I would love to contribute the possibility to disable globally the validators through a configuration property. If @gsmet agrees on the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants