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

[JENKINS-36748] Not process null Triggers #2463

Merged
merged 3 commits into from
Jul 20, 2016

Conversation

fbelzunc
Copy link
Contributor

@ghost
Copy link

ghost commented Jul 18, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

}
} else {
LOGGER.log(Level.WARNING, "The job {0} has a syntactically incorrect config and is missing the cron spec for a trigger", p.getFullName());
Copy link
Member

@jtnord jtnord Jul 18, 2016

Choose a reason for hiding this comment

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

the spec is optional for a Trigger IIUC.
Hence the check should be inside if (!(t instanceof SCMTrigger && scmd.synchronousPolling)) rather than outside it, or the log level and message should be adjusted.

@fbelzunc fbelzunc closed this Jul 19, 2016
@fbelzunc fbelzunc reopened this Jul 19, 2016
@fbelzunc
Copy link
Contributor Author

@jtnord I think I correctly addressed your feedback.

@jtnord
Copy link
Member

jtnord commented Jul 19, 2016

🐝 - a unit test would be great to prevent a regression...

@oleg-nenashev
Copy link
Member

the fox is a bit overloaded by "improvement" changes, but LGTM

@oleg-nenashev
Copy link
Member

Oh, 🐝
@reviewbybees done

@oleg-nenashev oleg-nenashev added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Jul 20, 2016
@oleg-nenashev oleg-nenashev merged commit 40687bd into jenkinsci:master Jul 20, 2016
@KostyaSha
Copy link
Member

👎 for merging it without test.

@KostyaSha
Copy link
Member

Issue wasn't closed https://issues.jenkins-ci.org/browse/JENKINS-36748

// don't let that cancel the polling activity. report and move on.
LOGGER.log(Level.WARNING, t.getClass().getName() + ".run() failed for " + p, e);
if (!(t instanceof SCMTrigger && scmd.synchronousPolling)) {
if (t !=null && t.spec != null && t.tabs != null) {
Copy link
Member

Choose a reason for hiding this comment

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

tabs can't be null

Copy link
Member

Choose a reason for hiding this comment

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

Please describe the case when getTriggers().values() may return null.

Copy link
Member

Choose a reason for hiding this comment

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

tabs can be null even when they should not, see the JIRA issue. basically an XML pushed with some missing fields, or JobDSL configuration without a cron...
getTriggers() should not return null - but hey this is about robustness and we have a similar patterns elsewhere in Jenkins for this.

Copy link
Member

Choose a reason for hiding this comment

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

So where is the fix for real problem then?

Copy link
Member

Choose a reason for hiding this comment

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

@jtnord if you get getTriggers(), then values() will be non null always. So you need check for getTriggers() nullness firstly.

Copy link
Member

Choose a reason for hiding this comment

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

So where is the fix for real problem then

t.tabs != null

We can not check and validate everything on disk, or created from XML as we have no schema to validate against, unless you have some suggestions here ?

getTriggers() should not return null - but hey this is about robustness and we have a similar patterns elsewhere in Jenkins for this.

I should be more careful when I type.

getTriggers() could possibly contain a null value, rather than itself be null, don;t ask me how or where, it was just deemed safe given we had to check tabs to check more than the initially observered case.

if getTriggers can return null then this needs a separate fix (and a separate JIRA as the way to reproduce this would be different).

@KostyaSha
Copy link
Member

Trigger API requires right trigger initialisation and usage, i annotated them long time ago. If ghprb (and i sure that is) is using APIs in wrong ways, then core shouldn't be hacked for it.

@jtnord
Copy link
Member

jtnord commented Jul 21, 2016

Annotations can be violated in so many ways, they are compile time for code not run time.
This issue was form a job with some invalid syntax, as JobDSL allows you to create stuff like that :-(

I think whilst we can argue about creating garbage until the cows come home (there are many ways to do it) I think we can agree that a single garbage job should not impact other jobs from working correctly - and this was actually the case here.

@KostyaSha
Copy link
Member

and this was actually the case here.

waiting for test case then.

@jtnord
Copy link
Member

jtnord commented Jul 21, 2016

and this was actually the case here.

waiting for test case then.

It's coming.

@fbelzunc
Copy link
Contributor Author

@jtnord @KostyaSha Per your request #2482 was created.

  • Would you mind to validate it, please?

@jglick
Copy link
Member

jglick commented Jul 27, 2016

👎, this looks like the wrong fix. Basic validation of the content of fields like triggers should be done during deserialization, not at runtime.

  • RobustCollectionConvertor simply drops elements from a collection which cannot be deserialized. It will not insert nulls. So I doubt the issue is that the whole Trigger was dropped.
  • RobustReflectionConverter allows a reference-typed field to be nulled out if it cannot be deserialized. If a given field is required in a given class, readResolve must enforce that, for example by throwing IllegalStateException. Or more cleanly, XStream2.addCriticalField could be made a public API, or replaced by an annotation.

@KostyaSha
Copy link
Member

I think you are trying to fix nulls where they shouldn't be at all. With such assumption every few lines in jenkins code will have null checks.

@jglick
Copy link
Member

jglick commented Jul 27, 2016

Right, that is my point: it is better to fix malformed settings at the point of origin (configuration or deserialization).

@daniel-beck
Copy link
Member

@jglick

If a given field is required in a given class, readResolve must enforce that

Which it does, in Trigger#readResolve(). But GhprbTrigger overrides it. Pretty much a bug in that plugin. Nonetheless, this is a robustness improvement. Far from the first one in Jenkins.

@fbelzunc
Copy link
Contributor Author

The main problem that I see for the right fix is that it needs to be done in XStream and even if I try to do there, we will not pick up the fix until some years happens and we update the pom. So either, we can revert this change or we merge the test case #2482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants