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

Defending against past corrupt builds #651

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Sep 26, 2024

cc @jglick @lemeurherve

I've seen builds failing in the wild during junit step execution with an exception like

java.lang.NullPointerException: Cannot invoke "hudson.model.Run.getRootDir()" because "this.run" is null
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getDataFilePath(TestResultAction.java:154)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.loadCached(TestResultAction.java:317)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.load(TestResultAction.java:279)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getResult(TestResultAction.java:166)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getResult(TestResultAction.java:70)
	at PluginClassLoader for junit//hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:286)
	at PluginClassLoader for junit//hudson.tasks.test.TestResult.getPreviousResult(TestResult.java:146)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.getPreviousResult(TestResult.java:467)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.getPreviousResult(CaseResult.java:768)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.recomputeFailedSinceIfNeeded(CaseResult.java:669)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.freeze(CaseResult.java:950)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.freeze(SuiteResult.java:730)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.freeze(TestResult.java:1119)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.setResult(TestResultAction.java:125)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.<init>(TestResultAction.java:96)
	at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:301)
	at PluginClassLoader for junit//hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:62)
	at PluginClassLoader for junit//hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:27)
	at PluginClassLoader for workflow-step-api//org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

While the root cause for such corruption is still to be identified, the plugin should defend against that condition and ignore such a build.

Similar to jenkinsci/parallel-test-executor-plugin#282

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

I've seen builds failing in the wild during `junit` step execution with
an exception like

```
java.lang.NullPointerException: Cannot invoke "hudson.model.Run.getRootDir()" because "this.run" is null
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getDataFilePath(TestResultAction.java:154)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.loadCached(TestResultAction.java:317)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.load(TestResultAction.java:279)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getResult(TestResultAction.java:166)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.getResult(TestResultAction.java:70)
	at PluginClassLoader for junit//hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:286)
	at PluginClassLoader for junit//hudson.tasks.test.TestResult.getPreviousResult(TestResult.java:146)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.getPreviousResult(TestResult.java:467)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.getPreviousResult(CaseResult.java:768)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.recomputeFailedSinceIfNeeded(CaseResult.java:669)
	at PluginClassLoader for junit//hudson.tasks.junit.CaseResult.freeze(CaseResult.java:950)
	at PluginClassLoader for junit//hudson.tasks.junit.SuiteResult.freeze(SuiteResult.java:730)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResult.freeze(TestResult.java:1119)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.setResult(TestResultAction.java:125)
	at PluginClassLoader for junit//hudson.tasks.junit.TestResultAction.<init>(TestResultAction.java:96)
	at PluginClassLoader for junit//hudson.tasks.junit.JUnitResultArchiver.parseAndSummarize(JUnitResultArchiver.java:301)
	at PluginClassLoader for junit//hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:62)
	at PluginClassLoader for junit//hudson.tasks.junit.pipeline.JUnitResultsStepExecution.run(JUnitResultsStepExecution.java:27)
	at PluginClassLoader for workflow-step-api//org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
```

While the root cause for such corruption is still to be identified, the
plugin should defend against that condition and ignore such a build.

Similar to jenkinsci/parallel-test-executor-plugin#282
@Vlatombe Vlatombe requested a review from a team as a code owner September 26, 2024 07:55
while (true) {
b = b.getPreviousBuild();
if (b == null) {
return null;
}
AbstractTestResultAction r = b.getAction(getParentAction().getClass());
Copy link
Member Author

Choose a reason for hiding this comment

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

(ignore ws)

This comment was marked as spam.

This comment was marked as spam.

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.

Thanks!

@timja timja enabled auto-merge (squash) September 26, 2024 08:18
@timja timja merged commit ab878c3 into jenkinsci:master Sep 26, 2024
16 of 17 checks passed
@Vlatombe Vlatombe deleted the defending-against-corrupt-build branch September 26, 2024 08:31
@Vlatombe
Copy link
Member Author

Thanks for the fast turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants