summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJohn Garbutt <john.garbutt@rackspace.com>2013-11-15 14:46:38 +0000
committerJohn Garbutt <john.garbutt@rackspace.com>2013-12-03 18:42:24 +0000
commit89b0d540d5f98945600139bd2a05656b68fac81a (patch)
tree02e6c39cc1fc059b18d39308135a2d702d306397 /plugins
parentdb86ec9237b02b3f896ade0f3ca7f66325eba164 (diff)
downloadnova-89b0d540d5f98945600139bd2a05656b68fac81a.tar.gz
xenapi: stop hang during glance download
It seems there are cases when the server gets stuck in a building state because the download from glance fails, but the nova-compute doesn't find out. After some code inspect, a likely cause seems to related to having no socket timeout inside urllib2 when we download the image from glance. A workaround for this issue is to configure the default socket timeout as described here: http://docs.python.org/3.1/howto/urllib2.html#sockets-and-layers Fixes bug 1251650 Change-Id: I8b34d95d3524f3825b28e61cbbb59290653d3711
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/xenserver/xenapi/etc/xapi.d/plugins/glance8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
index d5984c65d8..a281c5c7d7 100755
--- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance
@@ -22,6 +22,7 @@
import httplib
import md5
+import socket
import urllib2
import utils
@@ -33,12 +34,19 @@ pluginlib_nova.configure_logging('glance')
logging = pluginlib_nova.logging
PluginError = pluginlib_nova.PluginError
+DEFAULT_SOCKET_TIMEOUT_SECONDS = 60
+
class RetryableError(Exception):
pass
def _download_tarball_and_verify(request, staging_path):
+ # NOTE(johngarbutt) to ensure the script does not hang
+ # if we lose connection to glance we add a default socket
+ # The default is to never timeout.
+ socket.setdefaulttimeout(DEFAULT_SOCKET_TIMEOUT_SECONDS)
+
try:
response = urllib2.urlopen(request)
except urllib2.HTTPError, error: