Skip to content

Conversation

@jglick
Copy link
Member

@jglick jglick commented Feb 7, 2025

Amending #472 as I think I finally tracked down the problem with TestResultAction that I was trying without success to fix in #485. Ultimately this feels like a bug, or at least an anomaly, in core since jenkinsci/jenkins@50f7aa3 defined the Run.reload method with a vague comment saying that onLoad was not to be called since reload would be used from one Run constructor overload (which it is; in this PR that call site will not activate the patched behavior) but also that some unidentified uses do not want to be called multiple times. The latter part makes no sense, since this is on a fresh RunAction2 instance each time, and due to lazy loading that might already be true. This only seems to affect CloudBees CI, which calls this method in HA mode, since I am not aware of any call to Run.reload except via the load-from-disk constructor.

@jglick jglick added the bug label Feb 7, 2025
@jglick jglick requested review from Vlatombe and dwnusbaum February 7, 2025 18:51
assertThat("right owner after reload", b.getExecution().getOwner(), is(b.asFlowExecutionOwner()));
a = b.getAction(A.class);
assertThat("not attached in this instance", a.attached, is(0));
assertThat("loaded", a.loaded, is(1));
Copy link
Member Author

Choose a reason for hiding this comment

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

Without patch, this is zero, as in observed stack traces.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

Seems fine if it works and passes PCT

* Unfortunately {@link #reload} can be called either directly or implicitly via {@link #WorkflowRun(WorkflowJob, File)}
* and this is the only way to tell which of those cases this is.
*/
private transient volatile boolean loaded;
Copy link
Member

@dwnusbaum dwnusbaum Feb 7, 2025

Choose a reason for hiding this comment

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

FWIW, I find the naming of this field very confusing given the use down below. I guess the clearer thing would be to set the flag only from WorkflowRun(WorkflowJob, File), then change the name (to something like willCallOnLoadImplicitly) and invert the condition in reload here, but IIUC we can't do that because we have to call super(), which calls reload(), so we can't set a field in time.

I think "Early assignment to fields" in https://openjdk.org/jeps/492 would allow us to use a more straightforward approach here, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

the clearer thing would be to

I went through the same thought process, and yes I think JEP-492 would be helpful here.

@jglick jglick marked this pull request as ready for review February 7, 2025 23:13
@jglick jglick requested a review from a team as a code owner February 7, 2025 23:13
@jglick jglick merged commit ea4b20a into jenkinsci:master Feb 7, 2025
17 checks passed
@jglick jglick deleted the reloadOwnerAndActions branch February 7, 2025 23:17
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.

2 participants