Bug 2030692 - NPE in PipelineJobListener.upsertWorkflowJob
Summary: NPE in PipelineJobListener.upsertWorkflowJob
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Jenkins
Version: 4.8
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.10.0
Assignee: Gabe Montero
QA Contact: Jitendar Singh
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-12-09 13:59 UTC by Gabe Montero
Modified: 2022-03-10 16:33 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
* Before this update, version 1.0.48 of the OpenShift Jenkins Sync Plugin introduced a `NullPointerException` error when Jenkins notified the plug-in of new jobs that were not associated with an OpenShift Jenkins Pipeline Build Strategy Build Config. Ultimately, this error was benign because there was no `BuildConfig` object to associate with the incoming Jenkins Job. Core Jenkins ignored the exception in our plug-in and moved on to the next listener. However, a long stack trace showed up in the Jenkins log that distracted users. With this update, the plug-in resolves the issue by making the proper checks to avoid this error. (link:https://bugzilla.redhat.com/show_bug.cgi?id=2030692[BZ#2030692])
Clone Of:
Environment:
Last Closed: 2022-03-10 16:32:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift jenkins-sync-plugin pull 407 0 None open Bug 2030692: Fix benign PipelineJobLister NPE when workitem is not a openshift jenkins pipeline strategy build 2021-12-09 16:32:19 UTC
Red Hat Product Errata RHSA-2022:0056 0 None None None 2022-03-10 16:33:08 UTC

Description Gabe Montero 2021-12-09 13:59:14 UTC
Description of problem:

Per an exchange with an internal consumer at https://coreos.slack.com/archives/CNU6JC8GJ/p1639018303084900

The are extending our 4.8 Jenkins image, and with the latest version, have started seeing this NPE (full stack trace in slack thread):

java.lang.NullPointerException
	at io.fabric8.jenkins.openshiftsync.PipelineJobListener.upsertWorkflowJob(PipelineJobListener.java:169)
	at io.fabric8.jenkins.openshiftsync.PipelineJobListener.upsertItem(PipelineJobListener.java:148)
	at io.fabric8.jenkins.openshiftsync.PipelineJobListener.onCreated(PipelineJobListener.java:90)
	at hudson.model.listeners.ItemListener.lambda$fireOnCreated$1(ItemListener.java:217)
	at hudson.model.listeners.ItemListener.forAll(ItemListener.java:178)
	at hudson.model.listeners.ItemListener.fireOnCreated(ItemListener.java:215)
	at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:291)
	at jenkins.model.Jenkins.createProjectFromXML(Jenkins.java:4096)


at this time, this maps to this line in the method:

String ns = property.getNamespace();

where that property object was previously populated by

 BuildConfigProjectProperty property = buildConfigProjectForJob(job);


So why is the BuildConfigProjectProperty not associated with the job?
1) they are creating a project ... perhaps there is a timing issue and the BuildConfigProjectProperty is not created yet?
2) the plugin combination they have constructed is somehow breaking other function
3) this in fact is not a jenkins pipeline strategy job, and we should just ignore.

Minimally, we should move the get Namespace call in the if block with the null check.

We then need to consider whether we put this create event in a queue to periodically retry.

Comment 1 Gabe Montero 2021-12-09 14:30:08 UTC
Alice FYI ... this fix is separate from the other stuff you are tracking right now.

If you think you are going to touch PipelineJobListener, perhaps you can at least address the NPE, by not calling property.GetNamespace() unless property is non null.

But if you don't think you are going to touch it, I'll get a PR up real quick to fix it.

Comment 3 Gabe Montero 2021-12-09 16:25:35 UTC
ok this looks like a benign but noisy / distracting NPE for users

1) it is the case where the incoming workitem is NOT associated with a jenkins pipeline strategy build config
2) jenkins catches this exception and moves onto the next registered listener ... the associated job is still created

Comment 10 Priti Kumari 2022-01-05 08:43:25 UTC
I have already verified the `NullPointerException` thing with https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=1830329, which was released in https://bugzilla.redhat.com/show_bug.cgi?id=2016058 and I did not find any such error

Comment 13 Rolfe Dlugy-Hegwer 2022-02-17 20:51:42 UTC
Release noted in 4.10 with https://github.com/openshift/openshift-docs/pull/40899

Comment 16 errata-xmlrpc 2022-03-10 16:32:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.10.3 security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:0056


Note You need to log in before you can comment on or make changes to this bug.