Skip to content

Commit

Permalink
Revert "[JENKINS-32190] Make UsageStatistics#isDue check Jenkins init…
Browse files Browse the repository at this point in the history
… level before generating stats."

This reverts commit d8a13ac.

I noticed a strange drop in usage statistics from the mid Jan 2016,
which corresponds to the time this change was released in the wild,
and further drop when LTS 1.642.2 is released with this change at
the end of Feb.

I spent some time trying to determine how this might cause instances
to stop sending data, but I couldn't come up with any. I left those
notes in JENKINS-32190. There was some strange behaviours, but none
explains what this is.

So I'd like to back out this change and see if that makes any impact
on the stats collection. If it backs up, then we know empirically
this change is to blame, so that would justify spending further
effort or come up with a fix from a different angle.

(cherry picked from commit b2013ed)
  • Loading branch information
kohsuke authored and olivergondza committed Mar 30, 2016
1 parent 205cf6f commit 3a44687
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions core/src/main/java/hudson/model/UsageStatistics.java
Expand Up @@ -31,7 +31,6 @@
import hudson.util.IOUtils;
import hudson.util.Secret;
import static hudson.util.TimeUnit2.DAYS;
import static hudson.init.InitMilestone.COMPLETED;

import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -96,12 +95,9 @@ public UsageStatistics(String keyImage) {
* Returns true if it's time for us to check for new version.
*/
public boolean isDue() {
final Jenkins j = Jenkins.getInstance();
// user opted out or Jenkins not fully initialized. no data collection.
if (j == null || j.isUsageStatisticsCollected() || DISABLED || COMPLETED.compareTo(j.getInitLevel()) > 0) {
return false;
}

// user opted out. no data collection.
if(!Jenkins.getInstance().isUsageStatisticsCollected() || DISABLED) return false;

long now = System.currentTimeMillis();
if(now - lastAttempt > DAY) {
lastAttempt = now;
Expand Down

0 comments on commit 3a44687

Please sign in to comment.