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

Making sure ArgumentsAction is attached in time for GraphListener.Synchronous notification #254

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 4, 2018

Downstream of jenkinsci/workflow-support-plugin#75. Extracted from #252 as an independently releasable fix necessary to avoid regressing StepNodeTest (specifically, proper display of metasteps in the classic UI console) after changes in JEP-210. Specifically, as of jenkinsci/workflow-job-plugin#27 (comment) FlowNode.getDisplayFunctionName is called from within a synchronous listener. (Formerly this was an asynchronous listener, which sounds wrong but then again copyLogs was asynchronous too so who cared?) And this method call pays attention to ArgumentsAction to display, for example, archiveArtifacts rather than step (the generic function name of CoreStep). So we need to ensure that at least this basic metadata about the FlowNode is actually present by the time listeners are told about it. Some other metadata gets added later, like LabelAction, but we tolerate that—the new console UI renders the label via a ConsoleNote, potentially much later, at which point the label is known.

A FlowNode was being sent to GraphListener.Synchronous without ArgumentsAction available.

(cherry picked from commit e8953b5)
@svanoort
Copy link
Member

svanoort commented Oct 4, 2018

For those who will be equally confused about the key missing piece: this depends on the upstream PR because we need to be able to get the Environment a bit early (before we have the FlowNode set up and everything).

@jglick
Copy link
Member Author

jglick commented Oct 4, 2018

Note that the entire reason ArgumentsActionImpl needs an EnvVars to begin with is a hack. See JENKINS-47101 for discussion.

@jenkinsci jenkinsci deleted a comment from jglick Oct 4, 2018
final CpsStepContext context = new CpsStepContext(d,thread,handle,an,ps.body);
// Ensure ArgumentsAction is attached before we notify even synchronous listeners:
final CpsStepContext context = new CpsStepContext(d, thread, handle, an, ps.body);
try {
Copy link
Member

Choose a reason for hiding this comment

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

I think that you want the classloader switch to happen before the try block for safety, no? Or is there a reason why we shouldn't continue running this logic under the CpsVmExecutorService.ORIGINAL_CONTEXT_CLASS_LOADER.get() anymore?

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 never needed to be run with a special CCL to begin with. That is just where you happened to drop that new code. The CCL is for user code, mainly StepExecution.start implementations.

Copy link
Member

Choose a reason for hiding this comment

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

The ORIGINAL_CONTEXT_CLASSLOADER is for non-Groovy code though IIRC -- and IIRC we are switching away from the GroovyClassLoader to avoid stuff being loaded there (and potential memory leaks or issues with classloaders not matching).

I think you still want this to be happening with the non-Groovy classloader.

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 ORIGINAL_CONTEXT_CLASSLOADER is for non-Groovy code though

For non-Groovy plugin code, yes.

we are switching away from the GroovyClassLoader to avoid stuff being loaded there (and potential memory leaks or issues with classloaders not matching)

We are switching to the CCL used for general plugin Java code while we run the general plugin Java code: StepDescriptor.newInstance, Step.start, and (especially) StepExecution.start. ArgumentsActionImpl has nothing to do with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

FTR this system is from #50. #98 happened to drop ArgumentsActionImpl into the same try block as a convenience AFAICT—because it was checking for instanceof ParallelStep, which can only be done after instantiating the Step. This PR instead checks the StepDescriptor, which can be done earlier.

Copy link
Member

@svanoort svanoort left a comment

Choose a reason for hiding this comment

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

The contextClassLoader change makes me twitchy, but I can't see an obvious bug.

@jglick jglick merged commit ab1ef18 into jenkinsci:master Oct 4, 2018
@jglick jglick deleted the DSL+ArgumentsAction branch October 4, 2018 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants