Skip to content

Commit

Permalink
[JENKINS-34705] - Prevent hanging of InstallationWizard if internet c…
Browse files Browse the repository at this point in the history
…heck is skipped (#2328)
  • Loading branch information
oleg-nenashev committed May 12, 2016
1 parent d3b61b9 commit 930f630
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/hudson/model/UpdateCenter.java
Expand Up @@ -197,6 +197,12 @@ static enum ConnectionStatus {
* 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.
*/
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/hudson/model/UpdateSite.java
Expand Up @@ -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/";
Expand Down
7 changes: 6 additions & 1 deletion war/src/main/js/util/jenkins.js
Expand Up @@ -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);
}
Expand Down

0 comments on commit 930f630

Please sign in to comment.