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

FINERACT-982 - Completely ditch use of Drizzle JDBC Driver #1366

Closed
wants to merge 1 commit into from

Conversation

xurror
Copy link
Contributor

@xurror xurror commented Oct 2, 2020

@xurror
Copy link
Contributor Author

xurror commented Oct 2, 2020

I won't bet on this passing the build. I ran tests locally 3 times but some schedular jobs test kept failing. I guess schedular jobs will just do their thing.
But if this passes then it's cool

@vidakovic
Copy link
Contributor

I would externalize all references to specific drivers. What I mean with that is: instead of hard-coding the driver's class names and connection strings I would replace it with environment variables. Defaults for those variables would be the Drizzle related settings (for license compatibility), but anyone running Fineract in production (I guess that's the concern here) would then overwrite those environment variables either in the docker-compose.yml file or on the command line. That way no tricks have to be applied during releases and we don't have to reference the LGPL driver in this repository... which - as much as I understand it - we actually can't (LGPL being incompatible with Apache License 2)... unless I'm missing anything here?

@xurror
Copy link
Contributor Author

xurror commented Oct 2, 2020

@vidakovic I think we also have a challenge using the current config in development as it causes challenges during testing. You can follow discussion here on why these changes are the way they are: https://issues.apache.org/jira/browse/FINERACT-982 https://issues.apache.org/jira/browse/FINERACT-980.
But I like your suggestions very much, just think it will be a PITA to be setting env variables each time we trying to run tests. Makes it hard for us and for new contributors.
What do you think?

FYI: @vorburger @ptuomola @awasum

@vidakovic
Copy link
Contributor

In the end there are various mechanisms that we could use here to set different properties (e. g. Spring profiles)... agreed, tests would need maybe a bit of thinking... 

The one thing that seems to me unsolvable (disclaimer: I'm not a lawyer) is the dependency reference to the LGPL jar. And if we can't include that then the devs have to do manual fiddling anyway.

Easiest in terms of contributors would be (but these are more long-term - if it all - solutions that are more intrusive):

  • fix Drizzle and bring it to the same quality level as the "official" drivers (I think that's going to take a while)
  • find another Apache License 2 compatible driver (searched already extensively; I'd say there is non available)
  • switch to PostgreSQL as the default database (but you would still have a lot of people who want/need MySQL; so that wouldn't solve their problem)

Just spitballing...

@xurror
Copy link
Contributor Author

xurror commented Oct 2, 2020

Adopting profiles was my first option too. Perhaps we could get more inputs how to go about this from the community.

@vidakovic
Copy link
Contributor

👍

@vidakovic
Copy link
Contributor

Ok, I think I have a bit more info how other Apache projects deal with the issue of (L)GPL licensed libraries. See e. g. https://github.com/apache/camel/blob/master/components/camel-debezium-mysql/pom.xml. The important part to note here is the dependency scope ("provided") which means they don't include the dependency in the final build artifact. As far as I know the closest equivalent in Gradle should be compileOnly. That means that at least from the IDE perspective this issue should be solved (e. g. IntelliJ doesn't make a distinction between these scopes). Not sure if that applies also for running unit tests on the console, would need to test. It will not be included in the release package or Docker images (automatically). The current Dockerfile does download mysql-connector-j from Maven Central with a wget command and the jar file is then included to the Fineract startup with "java -cp"... I guess that means the Docker images are not considered release artifacts.

Just FYI

@xurror
Copy link
Contributor Author

xurror commented Oct 3, 2020

Nice digging. I'll try it out.

Copy link
Member

@vorburger vorburger left a comment

Choose a reason for hiding this comment

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

NOK, as is - but close! This is cool, and long overdue.. hope you can finish this to a state where it's OK to merge!

Comment on lines +382 to +389
PRE-RELEASE NOTICE: Please before starting any release process, ensure that the you have replaced mysql connector package from mariadb connector/j back to drizzle driver. Files requiring changes are:
* docker-compose.yml
* fineract-provider/build.gradle
* fineract-provider/src/main/resources/META-INF/spring/jdbc.properties
* kubernetes/fineract-server-deployment.yml

Copy link
Member

Choose a reason for hiding this comment

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

Nah, this will be super confusing... we cannot (should not) have the release be anything different than what we work with during development. Let's figure out a way to avoid this. My proposal is that we simply do not ship any JDBD driver in the Fineract distribution at all, ever.

Instead, why don't we just include a 2-3 lines trivial small fineract.sh script illustrating how to launch java ... with both fineract.jar and mariadb-java-client-2.7.0.jar on the CP? And document that in https://github.com/apache/fineract#instructions-to-build-the-jar-file as well (and also a word about having to add it to Tomcat when using the WAR), as part of this PR. And then we could entirely remove this section for "special instructions" for Releasing. WDYT?

As for actually getting the mariadb-java-client-2.7.0.jar, it must be available somewhere under .gradle/ or so? I'm not just where you can find it... or we could just wget (or curl - whatever) the MariaDB Connector/J?

@@ -80,7 +79,8 @@ dependencies {

'com.github.spotbugs:spotbugs-annotations',
'io.swagger.core.v3:swagger-annotations',
'org.webjars:webjars-locator-core'
'org.webjars:webjars-locator-core',
mysqlConnector
Copy link
Member

Choose a reason for hiding this comment

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

So this, unfortunately, as I understand it, is No Go. This would mean that we include a LGPL into the distro. Or that we would have to make special handstands to remove it again when we release to distribute, which I fear will be too confusing.

What we CAN do, as far as my understanding goes, is to have a test only scope dependency. So for unit tests, it's on the classpath, but it's never "packaged" and distributed. We currently only have one Spring Integration Test, but I would still do add it, with another scope than implementation, but some... test only something (whatever the right name is).

@@ -29,6 +29,8 @@ repositories {
}

project.ext.jerseyVersion = '1.19.4'
project.ext.mysqlConnector = 'org.mariadb.jdbc:mariadb-java-client'
Copy link
Member

Choose a reason for hiding this comment

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

how about ditching the mysql prefix from the name here, and just calling this (and the following)... maybe jdbcArtifact and jdbcVersion?

@vorburger
Copy link
Member

Not sure if that applies also for running unit tests on the console, would need to test.

So for ./gradlew integrationTest to work with what I have proposed above, where I suggest that we do NOT include any JDBC driver JAR into the WAR, we would just have to add it (a JDBC driver) to the external Tomcat which we start for running the ITs. This, hopefully, shouldn't actually be that hard - note the extraClasspath and sharedClasspath properties, which we should be able to use somewhere in our Cargo plugin configuration?

@xurror
Copy link
Contributor Author

xurror commented Oct 4, 2020 via email

@vorburger
Copy link
Member

vorburger commented Oct 4, 2020 via email

@xurror xurror marked this pull request as draft November 14, 2020 06:48
@github-actions
Copy link

This pull request seems to be stale. Are you still planning to work on it? We will automatically close it in 30 days.

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 this pull request may close these issues.

3 participants