Add registry_client_timeout parameter

Add a "registry_client_timeout" parameter which specifies the
time, in seconds, that an API server will wait for a registry
request to complete.

This prevents API clients hanging indefinitely in the event
that the registry becomes unresponsive.

Addresses LP bug 1089391.

Change-Id: Ib27b6eecdcb65cbe644c156a0ca5cd0d0b4638dd
This commit is contained in:
Stuart McLaren 2012-12-12 13:25:20 +00:00
parent 7324ffd4c5
commit a12f09fa96
4 changed files with 18 additions and 0 deletions

View File

@ -235,6 +235,14 @@ When using SSL in connections to the registry server, do not require
validation via a certifying authority. This is the registry's equivalent of
specifying --insecure on the command line using glanceclient for the API
* ``registry_client_timeout=SECONDS``
Optional. Default: ``600``.
The period of time, in seconds, that the API server will wait for a registry
request to complete. A value of '0' implies no timeout.
Configuring Logging in Glance
-----------------------------

View File

@ -137,6 +137,11 @@ registry_client_protocol = http
# Default: False
#registry_client_insecure = False
# The period of time, in seconds, that the API server will wait for a registry
# request to complete. A value of '0' implies no timeout.
# Default: 600
#registry_client_timeout = 600
# ============ Notification System Options =====================
# Notifications can be sent when images are create, updated or deleted.

View File

@ -197,6 +197,9 @@ class BaseClient(object):
self.host = host
self.port = port or self.DEFAULT_PORT
self.timeout = timeout
# A value of '0' implies never timeout
if timeout == 0:
self.timeout = None
self.use_ssl = use_ssl
self.auth_tok = auth_tok
self.creds = creds or {}

View File

@ -38,6 +38,7 @@ registry_client_opts = [
cfg.StrOpt('registry_client_cert_file'),
cfg.StrOpt('registry_client_ca_file'),
cfg.BoolOpt('registry_client_insecure', default=False),
cfg.IntOpt('registry_client_timeout', default=600),
cfg.StrOpt('metadata_encryption_key', secret=True),
]
registry_client_ctx_opts = [
@ -87,6 +88,7 @@ def configure_registry_client():
'cert_file': CONF.registry_client_cert_file,
'ca_file': CONF.registry_client_ca_file,
'insecure': CONF.registry_client_insecure,
'timeout': CONF.registry_client_timeout,
}