Indeed it sems that when posting an xml to update a job the 
ItemListener.onUpdated is not called. Only the Saveablelistener is called:
https://github.com/jenkinsci/jenkins/blob/5dfdc5f463b8987d87f5a01754ee45ad58e9ff4c/core/src/main/java/hudson/model/AbstractItem.java#L909

While when creating a job then ItemListener.onCreated is called but not the 
SaveableListener.onChange (well actually it is not a change so this is probably 
ok)

I don’t know how JobDSL works internally but if it is also posting an xml and 
thus also calling the updateByXML method then it is the same root cause. 
Implementing also the SaveableListener might do the trick.
I would consider this a bug in core, but maybe others think it works as 
designed though.

From: jenkinsci-dev@googlegroups.com <jenkinsci-dev@googlegroups.com> On Behalf 
Of Tomas Bjerre
Sent: Donnerstag, 23. Mai 2024 18:18
To: Jenkins Developers <jenkinsci-dev@googlegroups.com>
Subject: Re: Jenkins.getInstance().getAllItems(ParameterizedJob.class) slow in 
large installations

You don't often get email from 
tomas.bjerr...@gmail.com<mailto:tomas.bjerr...@gmail.com>. Learn why this is 
important<https://aka.ms/LearnAboutSenderIdentification>
I implemented and released Markus solution 2024-04-14. There are now 2 issues 
as a result of this change:
 - https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/311
 - https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/312

Both issues are scenarios where my ItemListener-implementation:
https://github.com/jenkinsci/generic-webhook-trigger-plugin/blob/3954ee99f8c8801877f6a9b998fe7fdcaa78e6d7/src/main/java/org/jenkinsci/plugins/gwt/jobfinder/JobFinderImpersonater.java#L20
Is not being invoked for the created jobs.

311 seems to be a bug in Job DSL, reported in 2021 here: 
https://issues.jenkins.io/browse/JENKINS-64553
312 might be a bug in Jenkins core? I could not find an existing Jira but 
perhaps one should be opened.

To answer Jesse, no I don't think it can be redesigned (without breaking API 
and forcing many of the 34k users to make big changes). But suggestions on that 
are very welcome.
måndag 15 april 2024 kl. 19:06:38 UTC+2 skrev 
jgl...@cloudbees.com<mailto:jgl...@cloudbees.com>:
On Sat, Apr 13, 2024 at 1:13 AM Tomas Bjerre <tomas.b...@gmail.com> wrote:
- Is there a faster way to 
Jenkins.getInstance().getAllItems(ParameterizedJob.class); ?

Yes, 
https://javadoc.jenkins.io/hudson/model/ItemGroup.html#allItems(java.lang.Class)
 is faster since it avoids the need to sort. Also if this code is running as a 
particular user identity yet the particular block of logic should apply 
regardless of the user’s permissions to learn of the existence of particular 
jobs, you can impersonate `ACL.SYSTEM` which will be faster since a typical 
`AuthorizationStrategy` implementation has a quick path for this principal.

Without knowing what the plugin does or why it is enumerating all projects in a 
performance-sensitive call site, I cannot offer further advice, but creating a 
cache smells like a poor solution. Can the plugin be redesigned to look up the 
required project by name rather than conducting a search?
--
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
jenkinsci-dev+unsubscr...@googlegroups.com<mailto:jenkinsci-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/5d851a22-9803-4b90-a905-4dca95817531n%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-dev/5d851a22-9803-4b90-a905-4dca95817531n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/DU0PR02MB7849D22FB61FD6E4DBD0C2C687F42%40DU0PR02MB7849.eurprd02.prod.outlook.com.

Reply via email to