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

Incorporate plugin health score in JSON metadata #840

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alecharp
Copy link
Contributor

@alecharp alecharp commented Feb 3, 2025

This adds the plugin health, from the https://github.com/jenkins-infra/plugin-health-scoring project, into the update-center output.

This is the first step to be able to display the scores in the Plugin Manager.

Testing

I tested on a limited number of plugins and it worked. I'm testing now with all plugins.

import okhttp3.Request;

public class HealthScores {
private static final String HEALTH_SCORES_URL = "https://reports.jenkins.io/plugin-health-scoring/scores.json";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rather than using the application endpoint, which generate the output on demand, this stores a static file, generated every hour IIRC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

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

First set of feedback/point of attention:

  • What is the impact on the size of the JSON metadatas? I have vague recollections of impacts due to adding even an integer field causing challenges. Of course it might be hard to evaluate: if it is the case, I would propose to start with generating both JSONs files (with and without the PH score), we keep deploying the "without PH score" and measure the impact in size and build/deploy time before going forward.

  • This PR adds a dependency on the service reports.jenkins.io. If the service is down or not reachable, what would be the expected fall backs? This webservice is "HA" (e.g. it has a QoS bound to the underlying Azure Kubernetes cluster today) but could be down.

@alecharp
Copy link
Contributor Author

alecharp commented Feb 3, 2025

  • What is the impact on the size of the JSON metadatas? I have vague recollections of impacts due to adding even an integer field causing challenges. Of course it might be hard to evaluate: if it is the case, I would propose to start with generating both JSONs files (with and without the PH score), we keep deploying the "without PH score" and measure the impact in size and build/deploy time before going forward.

I'll generate both and let you down the time required for the generation and the size the the files in each case.

  • This PR adds a dependency on the service reports.jenkins.io. If the service is down or not reachable, what would be the expected fall backs? This webservice is "HA" (e.g. it has a QoS bound to the underlying Azure Kubernetes cluster today) but could be down.

Technically, we already have this dependency:
https://github.com/jenkins-infra/update-center2/blob/master/src/main/java/io/jenkins/update_center/MaintainersSource.java#L47-L48. However, I'll try to see what happens and improve the code if needed for this situation.

@dduportal
Copy link
Contributor

I'll generate both and let you down the time required for the generation and the size the the files in each case.

I wasn't sure it was possible or easy for you (as the production dataset could be heavy, not even speaking about the cache...). Thanks!

Technically, we already have this dependency: https://github.com/jenkins-infra/update-center2/blob/master/src/main/java/io/jenkins/update_center/MaintainersSource.java#L47-L48. However, I'll try to see what happens and improve the code if needed for this situation.

OH: I was not aware. Then your change here does NOT add any dependency but reuse existing. It makes sense then (as per my infra hat: I can answer for the scope of the code itself).

@alecharp
Copy link
Contributor Author

alecharp commented Feb 3, 2025

So for the size:

❯ ls -al with*
with-health-score:
total 18528
drwxr-xr-x   5 alecharpe  *      160  3 fév 15:25 .
drwxr-xr-x  20 alecharpe  *      640  3 fév 15:28 ..
-rw-r--r--   1 alecharpe  *  3158562  3 fév 15:25 update-center.actual.json
-rw-r--r--   1 alecharpe  *  3158584  3 fév 15:25 update-center.json
-rw-r--r--   1 alecharpe  *  3158787  3 fév 15:25 update-center.json.html

without-health-score:
total 18312
drwxr-xr-x   5 alecharpe  *      160  3 fév 15:28 .
drwxr-xr-x  20 alecharpe  *      640  3 fév 15:28 ..
-rw-r--r--   1 alecharpe  *  3124324  3 fév 15:28 update-center.actual.json
-rw-r--r--   1 alecharpe  *  3124346  3 fév 15:28 update-center.json
-rw-r--r--   1 alecharpe  *  3124549  3 fév 15:28 update-center.json.html

For the timing, I ran the commands with an existing cache as downloading the files should not be part of the problem. As the health report is accessed / loaded once, this changeset should not be the biggest source of issues. Compared to accessing all the plugin GitHub repositories for example.

  • without the health score: java -Dfile.encoding=UTF-8 -jar --id default --www-dir without-health-score 14,61s user 1,77s system 14% cpu 1:55,94 total
  • with the health score: java -Dfile.encoding=UTF-8 -jar --id default --www-dir with-health-score 13,82s user 1,71s system 12% cpu 2:02,35 total

I'm still looking at what happens with no access to reports service.

@alecharp
Copy link
Contributor Author

alecharp commented Feb 3, 2025

So apparently, with reports.jenkins.io is down (blocked it locally), the master branch is not handling that well: it breaks the generation entirely.
I don't think there is a point of testing this scenario for this changeset. But that's something we can track to improve in the future.

@alecharp alecharp marked this pull request as ready for review February 3, 2025 15:45
@daniel-beck
Copy link
Contributor

daniel-beck commented Feb 3, 2025

So apparently, with reports.jenkins.io is down (blocked it locally), the master branch is not handling that well: it breaks the generation entirely. I don't think there is a point of testing this scenario for this changeset. But that's something we can track to improve in the future.

MaintainersSource and IssueTrackerSource (the two existing references to reports.jenkins.io) are written such that download failures generate warnings in the log. That it doesn't is a simple bug fixed in #841. Please use these classes as a blueprint how to download the data (and I should probably fix up Popularities in a similar way).

@daniel-beck daniel-beck changed the title Incorporates plugin health score in update-center data Incorporate plugin health score in JSON metadata Feb 3, 2025
@daniel-beck daniel-beck added enhancement This is an enhancement for the tool or wrapper scripts, typically adding features. java This PR affects Java code and would need a new release to be effective labels Feb 3, 2025
@daniel-beck daniel-beck self-requested a review February 3, 2025 16:04
@alecharp
Copy link
Contributor Author

alecharp commented Feb 3, 2025

Thanks @daniel-beck. Just improved the code to not fail if the report is not available.
I would like to take some time to see if we could remove the health score integer completely from the generated file if we didn't get a score. Cause, if we provide a 0 because reports service is down, that seems bad.

@alecharp alecharp marked this pull request as draft February 3, 2025 16:47
public int value;
}

public Integer getHealthScore(String pluginId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer not to have the boxing / unboxing but the current fastjson configuration do not serialise null field. Using an ObjectSerializer with another default value (like -1) is not working as only the value can be ignored from the serialisation, but the field name is generated anyway.

@alecharp alecharp marked this pull request as ready for review February 3, 2025 17:27
Copy link
Contributor

@daniel-beck daniel-beck left a comment

Choose a reason for hiding this comment

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

Looks reasonable 😃

src/main/java/io/jenkins/update_center/HealthScores.java Outdated Show resolved Hide resolved
src/main/java/io/jenkins/update_center/HealthScores.java Outdated Show resolved Hide resolved
import okhttp3.OkHttpClient;
import okhttp3.Request;

public class HealthScores {
Copy link
Contributor

Choose a reason for hiding this comment

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

Javadoc for this would be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just added what made sense to me. Please let me know if it's alright or if I need to improve it.

@daniel-beck daniel-beck added the on-hold This PR is on hold, typically because of a dependency to another change or event. label Feb 4, 2025
@daniel-beck
Copy link
Contributor

On-holding this, pending the corresponding core change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement for the tool or wrapper scripts, typically adding features. java This PR affects Java code and would need a new release to be effective on-hold This PR is on hold, typically because of a dependency to another change or event.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants