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

Introduce a new summary description field for jobs #4489

Closed
wants to merge 6 commits into from

Conversation

oleg-nenashev
Copy link
Member

@oleg-nenashev oleg-nenashev commented Feb 11, 2020

Draft implementation for my suggestion in #4477 which could be a solution which is acceptable to both sides (or not)

Proposed changelog entries

  • Bug: Reintroduce Build History truncation by default, allow managing it via a system property
  • Developer: Add support of a summary field for runs

Proposed upgrade guidelines

N/A

Submitter checklist

  • JIRA issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a JIRA issue should exist and be labeled as lts-candidate

@oleg-nenashev oleg-nenashev added the squash-merge-me Unclean or useless commit history, should be merged only with squash-merge label Feb 11, 2020
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

seems like the most pragmatic approach and what will satisfy the most users

@Exported
@CheckForNull
public String getSummary() {
return summary != null ? summary : getTruncatedDescription();
Copy link
Member

Choose a reason for hiding this comment

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

do you need to check if it's empty, or will it always be safely null here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer a strict data model here (good for getter performance), but I can add String truncation on the setter side

* @return The length-limited description.
* @deprecated truncated description uses arbitrary and unconfigurable limit of 100 symbols
* @deprecated truncated description based on the {@link #TRUNCATED_DESCRIPTION_LIMIT} setting.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

should this be un deprecated?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think no, because getSummary is a proper API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I would prefer to not change the state here.

Copy link
Member

Choose a reason for hiding this comment

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

I mentioned it as this PR adds documentation for it:
https://github.com/jenkinsci/jenkins/pull/4489/files#diff-c4f9931d88bca347279b881007d71f0eR234

Probably shouldn't be suggesting to call a deprecated API?

Copy link
Member

Choose a reason for hiding this comment

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

when compiling, we will have a warning because we are calling a deprecated api. I don't have solution, just worse mentioning that this is intentional, no?

Copy link
Contributor

@slonopotamus slonopotamus left a comment

Choose a reason for hiding this comment

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

I like this, assuming it will be possible to set summary via pipeline scripts. There are some bugs, though, thus marking PR as 'request changes'.

Additionally, you possibly want to allow editing of summary field on "Edit Build Information" page.

core/src/main/java/hudson/model/Run.java Outdated Show resolved Hide resolved
core/src/main/java/hudson/model/Run.java Outdated Show resolved Hide resolved
@oleg-nenashev
Copy link
Member Author

FTR introduction of a proper summary field is going to be an uphill battle. Jenkins core only includes the AbstractBuild implementation for UI, it will need updates in Pipeline plugins & Co

@@ -659,20 +679,42 @@ public final long getStartTimeInMillis() {
return startTime;
}

//TODO(oleg_nenashev): Do we want to export full description by default taking the size considerations? Looks like it should be another REST API or a flag
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder whether @harry-g and @jsoref use REST APIs for builds. The current state is a potentially big problem for long descriptions

Copy link
Contributor

Choose a reason for hiding this comment

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

Why would anything change for REST API? getDescription always returned full text.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's why I do not touch it. But I believe that it is not ideal for users who are concerned about huge REST APIs

Copy link

Choose a reason for hiding this comment

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

No, I think we don't use it afaik.
But I would also discourage delivering the full description with the build object.
(Where it is only one build run, so less severe than the current job/build with/config page which load description from tons of builds.)

Copy link
Member

Choose a reason for hiding this comment

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

Just decrease visibility if you don't like it here. People should be requesting it via ?tree anyway.

More of a separate change though.

@oleg-nenashev
Copy link
Member Author

[2020-02-11T16:25:25.753Z] [INFO] --- spotbugs-maven-plugin:3.1.12:check (spotbugs) @ jenkins-core ---

[2020-02-11T16:25:25.753Z] [INFO] BugInstance size is 1

[2020-02-11T16:25:25.753Z] [INFO] Error size is 0

[2020-02-11T16:25:25.753Z] [INFO] Total bugs: 1

[2020-02-11T16:25:25.753Z] [ERROR] Possible null pointer dereference of Run.description in hudson.model.Run.getTruncatedDescription() [hudson.model.Run, hudson.model.Run] Dereferenced at Run.java:[line 730]Known null at Run.java:[line 730] NP_NULL_ON_SOME_PATH

[2020-02-11T16:25:25.753Z] [INFO] 

@harry-g
Copy link

harry-g commented Feb 11, 2020

Just my 5 ct: the summary field would be nice if starting from scratch.
But with so many pipelines to modify for all users and also side effects like pipeline DSL itself and maybe some plugins depending on it, I think it is probably not the best way to go.

@harry-g
Copy link

harry-g commented Feb 11, 2020

Ups, sorry, I overlooked that the summary takes the truncated description if empty. Just thought that this could be the solution, then saw it is already in your change :-D
So pipelines do not need to be modified.
But as you said yourself

it will need updates in Pipeline plugins & Co

@res0nance
Copy link
Contributor

res0nance commented Feb 13, 2020

FTR introduction of a proper summary field is going to be an uphill battle. Jenkins core only includes the AbstractBuild implementation for UI, it will need updates in Pipeline plugins & Co

If we add something to https://github.com/jenkinsci/workflow-support-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java

We will be able to set it from pipeline with currentBuild.summary = "Some summary"

But it's an uphill battle due to having to bump core unless you use reflection :/

@slonopotamus
Copy link
Contributor

This reminds me of the "Epic Story of Adding a Boolean Field to git-plugin": jenkinsci/git-plugin#792. 3 weeks, 15 PR iterations, 56 comments, 16 changed files and 200 lines of changes. Things should not be that much complex.

Copy link
Contributor

@jsoref jsoref left a comment

Choose a reason for hiding this comment

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

I have no particular opinions about this.

I'm not a particular fan of having HTML magic here. If someone uses a different formatter, is there a reasonable way for this magic to work?

public @Nonnull String getTruncatedDescription() {
final int maxDescrLength = 100;
if (description == null || description.length() < maxDescrLength) {
public @CheckForNull String getTruncatedDescription() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be stylistically better to do:

@CheckForNull
public String ...

Copy link
Member Author

Choose a reason for hiding this comment

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

It would. Just following the historical codestyle

@oleg-nenashev
Copy link
Member Author

@jsoref

I'm not a particular fan of having HTML magic here. If someone uses a different formatter, is there a reasonable way for this magic to work?

Me too, but this is the current state of affairs. We could add a new truncate() method to the markupFormatter extension so that the implementations can override it

@oleg-nenashev oleg-nenashev marked this pull request as ready for review February 14, 2020 10:59
@oleg-nenashev
Copy link
Member Author

Test failure is valid

  18.807 [id=76]	WARNING	o.e.j.s.h.ContextHandler$Context#log: Error while serving http://localhost:36647/jenkins/job/test0/1/configSubmit
net.sf.json.JSONException: JSONObject["summary"] not found.
	at net.sf.json.JSONObject.getString(JSONObject.java:2040)
	at hudson.model.Run.submit(Run.java:2545)
	at hudson.model.Run.doConfigSubmit(Run.java:2536)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)

@oleg-nenashev oleg-nenashev added bug For changelog: Minor bug. Will be listed after features developer Changes which impact plugin developers labels Feb 16, 2020
@oleg-nenashev
Copy link
Member Author

The Sunday's weekly is getting delayed, so maybe we could try to get this into the weekly

@oleg-nenashev oleg-nenashev requested a review from a team February 18, 2020 11:07
@daniel-beck
Copy link
Member

This one snuck up on me. Could I get a few more days to review?

@oleg-nenashev oleg-nenashev added the on-hold This pull request depends on another event/release, and it cannot be merged right now label Feb 19, 2020
@oleg-nenashev
Copy link
Member Author

@daniel-beck sure

@timja timja removed the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Feb 20, 2020
*/
@Exported
@CheckForNull
public String getSummary() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it have a suppressed warning for the use of a deprecated method?

Copy link
Contributor

@fcojfernandez fcojfernandez left a comment

Choose a reason for hiding this comment

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

+1 for this proposal. IMO, this new summary field should have been in the model since the beginning

Copy link
Member

@alecharp alecharp left a comment

Choose a reason for hiding this comment

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

We will be adding a deprecation warning at compile time, but it's not a big issue.

* @return The length-limited description.
* @deprecated truncated description uses arbitrary and unconfigurable limit of 100 symbols
* @deprecated truncated description based on the {@link #TRUNCATED_DESCRIPTION_LIMIT} setting.
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

when compiling, we will have a warning because we are calling a deprecated api. I don't have solution, just worse mentioning that this is intentional, no?

@daniel-beck
Copy link
Member

+1 for this proposal. IMO, this new summary field should have been in the model since the beginning

It's called the build name.

@oleg-nenashev
Copy link
Member Author

@daniel-beck do you still want to do a review? It is likely to miss the weekly. Looks like I will need to create a backportable version of a fix without new API

@daniel-beck
Copy link
Member

do you still want to do a review?

Yes.

It is likely to miss the weekly.

🤷‍♂

Not every open PR needs to go into 2.222. After #4506, #4365, #4463, and #4501, it's a busy enough release.

@daniel-beck daniel-beck added the plugin-api-changes Changes the API of Jenkins available for use in plugins. label Feb 24, 2020
@daniel-beck
Copy link
Member

@oleg-nenashev FWIW I consider jsoref#5 to be a nice standalone change, if you want something to make the LTS release less broken with long descriptions.

@daniel-beck
Copy link
Member

Why doesn't the summary field show up on (build)/configure or on (build)/? It exists in the API and (indirectly) side-panel only, and that makes it really difficult to even discover. The new API endpoint is not documented on (build)/api either.

Screenshot

Screenshot

Screenshot

There's also the weird API model that makes it impossible for short descriptions to tell whether an identical summary is set, or whether the summary is just the description. I guess this is to make the sidepanel code easier, but is just confusing.

Screenshot

There's also a bug where submitting (build)/configure for a build that has a summary set wipes the summary.

I'm undecided whether the entire summary concept makes sense to me -- see #4489 (comment) -- but this implementation has problems.

Copy link
Member

@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.

As above.

@daniel-beck daniel-beck added the needs-comments-resolved Comments in the PR need to be addressed before it can be considered for merging label Feb 24, 2020
@oleg-nenashev
Copy link
Member Author

Why doesn't the summary field show up on (build)/configure or on (build)/?

Suggested changelog documents it as a developer change. I do not plan to work on the rest of frontend until we coordinate delivery for Pipeline. #4489 (comment)

There's also a bug where submitting (build)/configure for a build that has a summary set wipes the summary

It is. I will probably detach the bugfix and the rest for now

@oleg-nenashev oleg-nenashev changed the title [JENKINS-61004] - Reintroduce Build History truncation by default, allow managing it via a system property + Summary field [JENKINS-61004, JENKINS-60299] - Reintroduce Build History truncation by default, allow managing it via a system property + Summary field Feb 28, 2020
@oleg-nenashev
Copy link
Member Author

New version is here: #4529
It removes the build summary concept

@oleg-nenashev oleg-nenashev added rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted and removed bug For changelog: Minor bug. Will be listed after features labels Mar 5, 2020
@oleg-nenashev oleg-nenashev changed the title [JENKINS-61004, JENKINS-60299] - Reintroduce Build History truncation by default, allow managing it via a system property + Summary field Introduce a new summary description field for jobs Mar 5, 2020
@varyvol
Copy link

varyvol commented Sep 3, 2020

#4529 was merged. So is this still necessary?

@alecharp alecharp added the unresolved-merge-conflict There is a merge conflict with the target branch. label Oct 1, 2020
@alecharp
Copy link
Member

alecharp commented Oct 1, 2020

@oleg-nenashev shouldn't we close this PR as #4529 was merged? Thanks.

@oleg-nenashev
Copy link
Member Author

oleg-nenashev commented Oct 1, 2020 via email

@alecharp
Copy link
Member

should we close this PR for now and you can re-open it when you have more time?

@rsandell rsandell added the proposed-for-close There is no consensus about feasibility of this PR, and maintainers do not see a way forward for it label Nov 6, 2020
@alecharp
Copy link
Member

I'm closing this PR for now, please reopen it when you will be able to work on it again.

@alecharp alecharp closed this Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer Changes which impact plugin developers needs-comments-resolved Comments in the PR need to be addressed before it can be considered for merging on-hold This pull request depends on another event/release, and it cannot be merged right now plugin-api-changes Changes the API of Jenkins available for use in plugins. proposed-for-close There is no consensus about feasibility of this PR, and maintainers do not see a way forward for it rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted squash-merge-me Unclean or useless commit history, should be merged only with squash-merge unresolved-merge-conflict There is a merge conflict with the target branch.
Projects
None yet