mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 13:32:24 +00:00
[SECURITY-24] Exponential back-off of retry.
If we fail to obtain the update center metadata, don't keep retrying every 15 seconds, but use exponential time out to avoid overloading our server in case of a problem.
This commit is contained in:
1 parent
74b6a5a084
commit
a296b00059
2 files changed
+18
-2
No files matched your search
@@ -59,6 +59,8 @@ Upcoming changes</a>
|
||||
Fixed NPE in Groovy script execution via CLI (<a href="https://issues.jenkins-ci.org/browse/JENKINS-12302">issue 12302</a>)
|
||||
<li class=bug>
|
||||
Fixed bug where a queued build could start while the previous build was still in its post production state.
|
||||
<li class=bug>
|
||||
Improved the error retry logic of update center retrieval.
|
||||
<li class=rfe>
|
||||
Supported programmatic retrieval/update of slave <tt>config.xml</tt>
|
||||
<li class=rfe>
|
||||
|
||||
@@ -35,6 +35,7 @@ import hudson.util.FormValidation.Kind;
|
||||
import hudson.util.HttpResponses;
|
||||
import hudson.util.IOUtils;
|
||||
import hudson.util.TextFile;
|
||||
import hudson.util.TimeUnit2;
|
||||
import hudson.util.VersionNumber;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSONException;
|
||||
@@ -107,6 +108,12 @@ public class UpdateSite {
|
||||
*/
|
||||
private transient volatile long lastAttempt = -1;
|
||||
|
||||
/**
|
||||
* If the attempt to fetch data fails, we progressively use longer time out before retrying,
|
||||
* to avoid overloading the server.
|
||||
*/
|
||||
private transient volatile long retryWindow;
|
||||
|
||||
/**
|
||||
* ID string for this update source.
|
||||
*/
|
||||
@@ -162,6 +169,7 @@ public class UpdateSite {
|
||||
}
|
||||
|
||||
LOGGER.info("Obtained the latest update center data file for UpdateSource " + id);
|
||||
retryWindow = 0;
|
||||
getDataFile().write(json);
|
||||
return FormValidation.ok();
|
||||
}
|
||||
@@ -278,8 +286,14 @@ public class UpdateSite {
|
||||
if(dataTimestamp==-1)
|
||||
dataTimestamp = getDataFile().file.lastModified();
|
||||
long now = System.currentTimeMillis();
|
||||
boolean due = now - dataTimestamp > DAY && now - lastAttempt > 15000;
|
||||
if(due) lastAttempt = now;
|
||||
|
||||
retryWindow = Math.max(retryWindow,SECONDS.toMillis(15));
|
||||
|
||||
boolean due = now - dataTimestamp > DAY && now - lastAttempt > retryWindow;
|
||||
if(due) {
|
||||
lastAttempt = now;
|
||||
retryWindow = Math.min(retryWindow*2, HOURS.toMillis(1)); // exponential back off but at most 1 hour
|
||||
}
|
||||
return due;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user