foojayio / discoapi

The foojay discovery api (discoapi) is made to discover java packages (jre/jdk) from different distributions.
GNU General Public License v2.0
111 stars 13 forks source link

Current API state and question about guidance for usage in client applications #44

Closed repolevedavaj closed 2 years ago

repolevedavaj commented 2 years ago

I am currently checking whether I can use the DiscoAPI as a replacement for my current solution which I use to resolve the download URL for a specific JDK distribution.

During the creation of some unit tests I discovered, that the API does not seem stable: First I call the /disco/v2.0/packages/jdks endpoint to get an ephemeral id. Afterwards, I call the endpoint /disco/v2.0/ephemeral_ids/{ephemeral_id} to get the download URL. I created unit tests for different versions of the Temurin and GraalVM distribution. Sometimes they work and sometimes they fail. I already validated that the call does not fail because of a timeout. It seems that I sometimes get already expired id's. Sometimes I even get an empty result after calling the /disco/v2.0/packages/jdks endpoint.

Is there a known issue, or is the API still under construction? I would like to use the API in a client library and do not have any backend which I can use to cache the results from your API to overcome such issues.

Thanks in advance.

HanSolo commented 2 years ago

The api will be under development as long as we will see new OpenJDK distributions and as long as we get feature requests BUT it should always be stable enough to work for such use cases. I've did a quick test and also stumbled upon such packages with already outdated ephemeral id's which should not be the case. We are currently working on an update which will hopefully also fix this issue. Thx for the heads up.

repolevedavaj commented 2 years ago

That sounds great - thanks for the quick feedback. Is there already planned date for the update, or an existing workaround I can use until the fix is deployed?

HanSolo commented 2 years ago

Could you send me an example request which fails on your side? With that I could probably give you a better advice for a workaround

repolevedavaj commented 2 years ago

Beside the expired ephemeral id, I have the problem, that I not always receive a result, if I call the /disco/v2.0/packages/jdks endpoint.

Example URL: https://api.foojay.io/disco/v2.0/packages/jdks?version=8u302-b08&distro=Temurin&architecture=x64&archive_type=tar.gz&operating_system=macos

Possible answer 1:

{
  "result":
  [],
  "message":"No package(s) found"
}

Possible answer 2:

{
  "result":
  [{"id":"c9305964ca63428272e987f399bb0e1c","archive_type":"tar.gz","distribution":"temurin","major_version":8,"java_version":"8.0.302+8","distribution_version":"8.0.302+8","latest_build_available":true,"release_status":"ga","term_of_support":"lts","operating_system":"macos","lib_c_type":"libc","architecture":"x64","package_type":"jdk","javafx_bundled":false,"directly_downloadable":true,"filename":"OpenJDK8U-jdk_x64_mac_hotspot_8u302b08.tar.gz","ephemeral_id":"3c490e2572d4c39564417a863fba03a29f31914d","links":{
"pkg_info_uri":"https://api.foojay.io/disco/v2.0/ephemeral_ids/3c490e2572d4c39564417a863fba03a29f31914d","pkg_download_redirect":"https://api.foojay.io/disco/v2.0/ephemeral_ids/3c490e2572d4c39564417a863fba03a29f31914d/redirect"},"free_use_in_production":true,"tck_tested":true,"feature":[]}],
  "message":"1 package(s) found"
}
HanSolo commented 2 years ago

There is no support for requesting the version-number incl. the build, so you should ask for version=8.0.302 or version=1.8.0_302 or version=8u302

repolevedavaj commented 2 years ago

Ah, I was not aware of that. I just tested the version as written on the Temurin download site: https://adoptium.net/releases.html?variant=openjdk8&jvmVariant=hotspot. But in this case, I would expect to always receive an empty result, which is currently not the case. I will change it in my tests and check if there are other API calls, which have the same behavior.

repolevedavaj commented 2 years ago

I implemented now a dirty retry mechanism which will be executed if I receive a 400 status code after calling /disco/v2.0/ephemeral_ids/{ephemeral_id} and it seems to workaround the problem.

Do you have a issue regarding the expired ephemeral id which I can follow to get notified about the status?

HanSolo commented 2 years ago

I'm waiting for the it guys to deploy the latest version which should fix those problems, unfortunately they are really busy but I'm confident the new release will be in production by next week...crossing fingers.

repolevedavaj commented 2 years ago

Sounds great, thanks! I it is OK for you, I will keep the ticket opened. If you want, you can close it after the deployment.

HanSolo commented 2 years ago

Absolutely ok with me...hope the it guys will be able to deploy asap...