Skip to content
Permalink
Browse files
[JENKINS-34705] - Prevent hanging of InstallationWizard if internet c…
…heck is skipped (#2328)
  • Loading branch information
oleg-nenashev committed May 12, 2016
1 parent d3b61b9 commit 930f6308a5e0b29a45b88b626f51b246107e2830
Showing with 19 additions and 2 deletions.
  1. +10 −0 core/src/main/java/hudson/model/UpdateCenter.java
  2. +3 −1 core/src/main/java/hudson/model/UpdateSite.java
  3. +6 −1 war/src/main/js/util/jenkins.js
@@ -197,6 +197,12 @@
* Connection status has not started yet.
*/
PRECHECK,
/**
* Connection status check has been skipped.
* As example, it may happen if there is no connection check URL defined for the site.
* @since TODO
*/
SKIPPED,
/**
* Connection status is being checked at this time.
*/
@@ -1378,6 +1384,10 @@ public void run() {
connectionStates.put(ConnectionStatus.INTERNET, ConnectionStatus.OK);
}
});
} else {
LOGGER.log(WARNING, "Update site '{0}' does not declare the connection check URL. "
+ "Skipping the network availability check.", site.getId());
connectionStates.put(ConnectionStatus.INTERNET, ConnectionStatus.SKIPPED);
}

connectionStates.put(ConnectionStatus.UPDATE_SITE, ConnectionStatus.CHECKING);
@@ -341,9 +341,11 @@ public Api getApi() {
}

/**
* Returns an "always up" server for Internet connectivity testing, or null if we are going to skip the test.
* Gets a URL for the Internet connection check.
* @return an "always up" server for Internet connectivity testing, or {@code null} if we are going to skip the test.
*/
@Exported
@CheckForNull
public String getConnectionCheckUrl() {
Data dt = getData();
if(dt==null) return "http://www.google.com/";
@@ -200,12 +200,17 @@ exports.testConnectivity = function(siteId, handler) {
handler(false, true, response.message);
}

// Define statuses, which need additional check iteration via async job on the Jenkins master
// Statuses like "OK" or "SKIPPED" are considered as fine.
var uncheckedStatuses = ['PRECHECK', 'CHECKING', 'UNCHECKED'];
if(uncheckedStatuses.indexOf(response.data.updatesite) >= 0 || uncheckedStatuses.indexOf(response.data.internet) >= 0) {
setTimeout(testConnectivity, 100);
}
else {
if(response.status !== 'ok' || response.data.updatesite !== 'OK' || response.data.internet !== 'OK') {
// Update site should be always reachable, but we do not require the internet connection
// if it's explicitly skipped by the update center
if(response.status !== 'ok' || response.data.updatesite !== 'OK' ||
(response.data.internet !== 'OK' && response.data.internet !== 'SKIPPED')) {
// no connectivity, but not fatal
handler(false, false);
}

0 comments on commit 930f630

Please sign in to comment.