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

Stop using Guice to inject InputStep & context parameters #69

Merged
merged 6 commits into from
Jan 19, 2022

Conversation

jglick
Copy link
Member

@jglick jglick commented Jan 3, 2022

Downstream of jenkinsci/workflow-step-api-plugin#81. Similar to #64 but should retain serial compatibility for steps running across the upgrade. Probably fixes jenkinsci/acceptance-test-harness#727.

@jglick jglick added the bug label Jan 3, 2022
@jglick jglick requested review from basil and car-roll January 3, 2022 23:41
} catch (IOException | InterruptedException | TimeoutException x) {
LOGGER.log(Level.WARNING, "failed to remove InputAction from " + run, x);
LOGGER.log(Level.WARNING, "failed to remove InputAction from " + getContext(), x);
Copy link
Member

Choose a reason for hiding this comment

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

Looks reasonable, but here and elsewhere where you call getContext() did you mean getRun()? That would make more sense to me as a direct translation of the old run variable.

Copy link
Member

Choose a reason for hiding this comment

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

(I see what you mean about GitHub not letting you comment on a single line without leaving a "review". I clicked "leave a single comment", yet now it appears as "reviewed 18 minutes ago.")

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@basil basil Jan 4, 2022

Choose a reason for hiding this comment

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

Got it, sounds good then.

@jglick
Copy link
Member Author

jglick commented Jan 4, 2022

It would be prudent for me to also add a @LocalData test demonstrating that #64 is incompatible while this is compatible.

@jglick
Copy link
Member Author

jglick commented Jan 4, 2022

Without using AbstractStepExecutionImpl (like in #64) the new InputStepTest.serialForm fails as expected:

an exception which occurred:
	in field org.jenkinsci.plugins.workflow.cps.CpsThread.step
	in object org.jenkinsci.plugins.workflow.cps.CpsThread@3954e084
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThread
	in object of type java.util.concurrent.ConcurrentSkipListMap
	in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.threads
	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7022d974
	in object of type org.jenkinsci.plugins.workflow.cps.CpsThreadGroup
Caused: java.io.InvalidClassException: org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution; Class does not extend stream superclass
	at org.jboss.marshalling.river.RiverUnmarshaller.doReadClassDescriptor(RiverUnmarshaller.java:1046)
	at …
	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader$SandboxedUnmarshaller.lambda$readObject$0(RiverReader.java:250)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:237)
	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader$SandboxedUnmarshaller.sandbox(RiverReader.java:237)
	at org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverReader$SandboxedUnmarshaller.readObject(RiverReader.java:250)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:793)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:786)
	at …
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.loadProgramAsync(CpsFlowExecution.java:783)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onLoad(CpsFlowExecution.java:750)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getExecution(WorkflowRun.java:691)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:550)
	at hudson.model.RunMap.retrieve(RunMap.java:225)
	at hudson.model.RunMap.retrieve(RunMap.java:57)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:501)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:483)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.getByNumber(AbstractLazyLoadRunMap.java:381)
	at hudson.model.RunMap.getById(RunMap.java:205)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.run(WorkflowRun.java:940)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.get(WorkflowRun.java:951)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$1.computeNext(FlowExecutionList.java:65)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$1.computeNext(FlowExecutionList.java:57)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl.onLoaded(FlowExecutionList.java:178)
	at jenkins.model.Jenkins.<init>(Jenkins.java:1019)
	at …
Caused: java.io.IOException: Failed to load build state
	at …
Finished: FAILURE

Without using AbstractStepImpl it in fact passes, suggesting jenkinsci/workflow-step-api-plugin#81 was not strictly necessary. strings program.dat | uniq | sort records the type InputStep but not its supertype for some reason (whereas the supertype of InputStepExecution is recorded). Not sure what is going on there, but at any rate it seems safer to retain the original supertype.

@jglick jglick marked this pull request as ready for review January 4, 2022 18:51
@jglick jglick requested review from basil and dwnusbaum January 4, 2022 18:51
@jglick
Copy link
Member Author

jglick commented Jan 4, 2022

$ strings src/test/resources/org/jenkinsci/plugins/workflow/support/steps/input/InputStepTest/serialForm/jobs/p/builds/1/program.dat | sort | uniq | fgrep Step
	>0org.jenkinsci.plugins.workflow.steps.StepContext
	>1org.jenkinsci.plugins.workflow.cps.CpsStepContext
	>2org.jenkinsci.plugins.workflow.steps.StepExecution
3><org.jenkinsci.plugins.workflow.support.steps.input.InputStep
	>9org.jenkinsci.plugins.workflow.support.DefaultStepContextG
	>Eorg.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution
	>>org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl

Possibly because StepExecution implements Serializable, so all supertypes leading back to that are part of the serial form, whereas InputStep extends AbstractStepImpl implements Serializable so (in the absence of any inherited fields) the supertype of InputStep is not part of the serial form? I guess I could revert jenkinsci/workflow-step-api-plugin#81 (I know, I should have written the test first) and make InputStep extend Step for simplicity though I am not entirely confident that is safe. No strong opinion.

@car-roll car-roll merged commit f27b0b8 into jenkinsci:master Jan 19, 2022
@jglick jglick deleted the guice branch January 19, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants