Skip to content

Extend startup notification timeout as jobs continue to be loaded #220

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<!-- remember to change the io.jenkins.tools.bom artifact when changing this -->
<jenkins.version>2.277.1</jenkins.version>
<jenkins.version>2.332.1</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<hpi.compatibleSinceVersion>5.2</hpi.compatibleSinceVersion>
Expand Down Expand Up @@ -58,8 +58,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.277.x</artifactId>
<version>984.vb5eaac999a7e</version>
<artifactId>bom-2.332.x</artifactId>
<version>1195.v33041c1f1b_b_2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public abstract class AbstractFolder<I extends TopLevelItem> extends AbstractIte
private static long loadingTick;
private static final AtomicInteger jobTotal = new AtomicInteger();
private static final AtomicInteger jobEncountered = new AtomicInteger();
private static final AtomicInteger jobEncounteredAtLastTick = new AtomicInteger();
private static final AtomicBoolean loadJobTotalRan = new AtomicBoolean();
private static final int TICK_INTERVAL = 15000;

Expand Down Expand Up @@ -565,8 +566,17 @@ public String call(I item) {
float percentage = 100.0f * jobEncountered.incrementAndGet() / Math.max(1, jobTotal.get());
long now = System.currentTimeMillis();
if (loadingTick == 0) {
// Buy ourselves two tick intervals to complete the first tick + some slop.
Jenkins.get().getLifecycle().onExtendTimeout(2 * TICK_INTERVAL, TimeUnit.MILLISECONDS);

loadingTick = now;
} else if (now - loadingTick > TICK_INTERVAL) {
// If we're still making progress loading jobs, buy ourselves another tick.
if (jobEncountered.get() > jobEncounteredAtLastTick.get()) {
Jenkins.get().getLifecycle().onExtendTimeout(TICK_INTERVAL, TimeUnit.MILLISECONDS);
}
jobEncounteredAtLastTick.set(jobEncountered.get());
Copy link
Member

Choose a reason for hiding this comment

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

There is probably some idiomatic way to do the compare and set atomically but I suppose we do not care much here since it is only a heuristic.

(Are these counters actually used from concurrent threads? Predates 869ef0c and I no longer recall!)

Copy link
Member Author

Choose a reason for hiding this comment

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

There is probably some idiomatic way to do the compare and set atomically

If there is such an idiomatic way, I cannot think of it.

Are these counters actually used from concurrent threads?

I am not familiar with this code, but reading it raised more questions than answers in my mind (i.e., it smelled wrong to me) so I decided not to think too hard about it.


LOGGER.log(Level.INFO, String.format("Loading job %s (%.1f%%)", fullName, percentage));
loadingTick = now;
}
Expand Down