Bug 2030692

Summary: NPE in PipelineJobListener.upsertWorkflowJob
Product: OpenShift Container Platform Reporter: Gabe Montero <gmontero>
Component: JenkinsAssignee: Gabe Montero <gmontero>
Status: CLOSED ERRATA QA Contact: Jitendar Singh <jitsingh>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.8CC: aos-bugs, gallen, irum, pbhattac, pkumari, spandura
Target Milestone: ---   
Target Release: 4.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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])
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-10 16:32:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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