odpi / egeria-connector-jdbc

JDBC connectors for Egeria (Integration and Resource)
Apache License 2.0
1 stars 6 forks source link

Build refactoring for generic connector #13

Closed planetf1 closed 1 year ago

planetf1 commented 2 years ago
planetf1 commented 2 years ago

At some point we need to update the gradle build files/cicd to publish a maven artefact - update here if/when you need help with that/are ready to do it.

The hardest part is probably deciding the name(s) of the artifacts(assuming we keep them all distinct)

This will mean the connector gets published -- even as a snapshot -- so it will be downloadable. Later we can consider released versions.

At that time we should probably add an 'enforcedPlatform' reference in the top level gradle file -- this will cause us to use the same versions as egeria (this is how we did it in the hive megastore connector)

planetf1 commented 2 years ago

Agreed in team meeting 30 Aug that I will make the change to get the new connectors published as maven artifacts

planetf1 commented 1 year ago

After the recent changes, we generate an action attachment containing the three connectors:

Screenshot 2022-11-03 at 10 21 36 Screenshot 2022-11-03 at 10 21 30
planetf1 commented 1 year ago

These are all being published - but with names based on the directory name. Either we need to move the directory to use as the default component name (our usual pattern in egeria) or explicitly specify the project name (probably the simplest for now)

Screenshot 2022-11-03 at 14 33 10 Screenshot 2022-11-03 at 14 33 16 Screenshot 2022-11-03 at 14 33 49

^^ These can be accessed NOW (since I merged the PR that I wrote before my vacation, but was awaiting review so only merged this morning)

I'll update the artifact names later in the week

planetf1 commented 1 year ago

^^ @dwolfson @lpalashevski @mandy-chessell

dwolfson commented 1 year ago

@planetf1 Thanks - I looked in both Maven Central and Sonatype for a jdbc.snapshot.jar but didn't see one? Am I looking for the wrong thing or looking in the wrong place?

planetf1 commented 1 year ago

The artifacts are only available on the SNAPSHOT repository, since we have not yet done a release for the database connectors (at least not the new ones). I did ask at the f2f but the consensus was not yet.

In the snapshot URL, as an example, the resource connector can currently be found under:

https://oss.sonatype.org/service/local/repositories/snapshots/content/org/odpi/egeria/jdbc-resource-connector/3.13-SNAPSHOT/

However, as these are snapshots, all files include the timestamp ,making it awkward to fetch

So you can issue a query like

wget http://oss.sonatype.org/service/local/artifact/maven/redirect\?r\=snapshots\&g\=org.odpi.egeria\&a\=jdbc-resource-connector\&v\=3.13-SNAPSHOT\&c\=jar

What this shows, however, is that the actual connector is not published ie:

Screenshot 2022-11-04 at 13 10 13

We have javadoc, sources, but no actual code ;-)

Thanks for spotting.

planetf1 commented 1 year ago

Connectors now being published with new names:

And...

As an example we can see this also now includes the jar correctly:

Screenshot 2022-11-04 at 13 47 26

At this point the http query isn't working - this may depend on an index update (or another bug?)

planetf1 commented 1 year ago

The http query will work -- for the jar, do not specify a classifier ie:

Note that both jars are currently built without dependencies. The integration connector does require the resource connector. Both require a jdbc connector for the database being used. I've not verified the runtime behaviour to see if anything else extra is required, though there should be no change here from previously

^ @davidradl @dwolfson @lcpopa

planetf1 commented 1 year ago

(extra points if anyone spots my error in the current code. cosmetic only!)

planetf1 commented 1 year ago

Inspecting .module file -- this is a gradle addition that provides additional metadata for gradle consumers

The top level metadata looks good:

  "component": {
    "group": "org.odpi.egeria",
    "module": "egeria-connector-integration-jdbc",
    "version": "3.13-SNAPSHOT",
    "attributes": {
      "org.gradle.status": "integration"
    }

The java jar is properly represented with:

Checking the pom

And the files

And the maven-metadata.xml

planetf1 commented 1 year ago

Checking retrieving the jar via curl:

➜  newc curl -L -X GET "http://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.odpi.egeria&a=egeria-connector-resource-jdbc&v=3.13-SNAPSHOT" --output egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   134  100   134    0     0    740      0 --:--:-- --:--:-- --:--:--   757
100   242  100   242    0     0     96      0  0:00:02  0:00:02 --:--:--   250
100  4550  100  4550    0     0   1741      0  0:00:02  0:00:02 --:--:--     0
➜  newc ls
egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
➜  newc file egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar: Zip archive data, at least v1.0 to extract, compression method=deflate
➜  newc jar -tf egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/odpi/
org/odpi/openmetadata/
org/odpi/openmetadata/adapters/
org/odpi/openmetadata/adapters/connectors/
org/odpi/openmetadata/adapters/connectors/resource/
org/odpi/openmetadata/adapters/connectors/resource/jdbc/
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnectorProvider.class
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnector.class
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnector$JdbcConnectorAsDataSource.class
➜  newc

This looks ok (repeat for any other connectors)

Next we check with the proper maven tools - and can see that again, the maven artifact is correctly downloaded:

➜  newc ls
➜  newc mvn dependency:get -DrepoUrl=https://oss.sonatype.org/content/repositories/snapshots -Dartifact=org.odpi.egeria:egeria-connector-resource-jdbc:3.13-SNAPSHOT -Ddest=egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ standalone-pom ---
[WARNING] repositoryUrl parameter is deprecated. Use remoteRepositories instead
[INFO] Resolving org.odpi.egeria:egeria-connector-resource-jdbc:jar:3.13-SNAPSHOT with transitive dependencies
Downloading from temp: https://oss.sonatype.org/content/repositories/snapshots/org/odpi/egeria/egeria-connector-resource-jdbc/3.13-SNAPSHOT/maven-metadata.xml
Downloaded from temp: https://oss.sonatype.org/content/repositories/snapshots/org/odpi/egeria/egeria-connector-resource-jdbc/3.13-SNAPSHOT/maven-metadata.xml (1.4 kB at 2.4 kB/s)
[WARNING] destination/dest parameter is deprecated: it will disappear in future version.
[INFO] Copying /Users/jonesn/.m2/repository/org/odpi/egeria/egeria-connector-resource-jdbc/3.13-SNAPSHOT/egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar to /private/tmp/newc/egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
[WARNING] Notice transitive dependencies won't be copied.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.976 s
[INFO] Finished at: 2022-11-07T14:21:05Z
[INFO] ------------------------------------------------------------------------
➜  newc ls
egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
➜  newc file *jar
egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar: Zip archive data, at least v1.0 to extract, compression method=deflate
➜  newc jar -tf egeria-connector-resource-jdbc-3.13-SNAPSHOT.jar
META-INF/
META-INF/MANIFEST.MF
org/
org/odpi/
org/odpi/openmetadata/
org/odpi/openmetadata/adapters/
org/odpi/openmetadata/adapters/connectors/
org/odpi/openmetadata/adapters/connectors/resource/
org/odpi/openmetadata/adapters/connectors/resource/jdbc/
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnector$JdbcConnectorAsDataSource.class
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnectorProvider.class
org/odpi/openmetadata/adapters/connectors/resource/jdbc/JdbcConnector.class
planetf1 commented 1 year ago

In summary - for this repo's publish flow:

I suggest these general issues are followed up in

Does that help @dwolfson @mandy-chessell ?

planetf1 commented 1 year ago

Tested with postgres connectors:

Using a file ~/etc/jdbc.yaml:

extralibs:
  - url: http://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.odpi.egeria&a=egeria-connector-resource-jdbc&v=3.13-SNAPSHOT"
    filename: egeria-connector-resource-jdbc.jar
  - url: http://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.odpi.egeria&a=egeria-connector-integration-jdbc&v=3.13-SNAPSHOT"
    filename: egeria-connector-integration-jdbc.jar
  - url: https://jdbc.postgresql.org/download/postgresql-42.5.0.jar
    filename: postgresql.jar

We can install an instance of the helm chart ie:

helm install lab egeria/odpi-egeria-lab --set jupyter.tokenPlain='s3cr3t!' --set strimzi.enabled=false --devel -f ~/etc/jdbc.yaml

This

➜ etc kubectl exec -it lab-odpi-egeria-lab-core-0 -- /bin/ls -la /deployments/server/extralib Defaulted container "egeria" out of: egeria, init-connector (init) total 1044 drwxrwsrwx. 2 root 1000840000 4096 Nov 7 15:16 . drwxr-xr-x. 1 root root 4096 Nov 7 15:16 .. -rw-r--r--. 1 1000840000 1000840000 793 Nov 7 15:16 egeria-connector-integration-jdbc.jar -rw-r--r--. 1 1000840000 1000840000 787 Nov 7 15:16 egeria-connector-resource-jdbc.jar -rw-r--r--. 1 1000840000 1000840000 1046274 Nov 7 15:16 postgresql.jar ➜ etc

planetf1 commented 1 year ago

Update on above - the connectors are the wrong content .The reason is that the specific URL specified utilizes a query which results in a http redirect as a response. In the charts we do not follow redirects, so the http redirect is downloaded, not the target of the redirect..

See https://github.com/odpi/egeria-charts/issues/207

planetf1 commented 1 year ago

This error was a user problem - missing quotes in the URL which then failed (incorrect end result, not a failure....) on the curl request Will look at whether any additional error checking can be done in the helm charts

The correct jdbc.yaml is:

extralibs:
  - url: "http://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.odpi.egeria&a=egeria-connector-resource-jdbc&v=3.13-SNAPSHOT"
    filename: egeria-connector-resource-jdbc.jar
  - url: "http://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=org.odpi.egeria&a=egeria-connector-integration-jdbc&v=3.13-SNAPSHOT"
    filename: egeria-connector-integration-jdbc.jar
  - url: "https://jdbc.postgresql.org/download/postgresql-42.5.0.jar"
    filename: postgresql.jar
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 20 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 20 days if no further activity occurs. Thank you for your contributions.

planetf1 commented 1 year ago

this was completed as part of the original work