Skip to content

Commit

Permalink
Add registry_client_timeout parameter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Stuart McLaren committed Dec 12, 2012
1 parent 7324ffd commit a12f09f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/source/configuring.rst
Expand Up @@ -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
-----------------------------

Expand Down
5 changes: 5 additions & 0 deletions etc/glance-api.conf
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions glance/common/client.py
Expand Up @@ -197,6 +197,9 @@ def __init__(self, host, port=None, timeout=None, use_ssl=False,
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 {}
Expand Down
2 changes: 2 additions & 0 deletions glance/registry/__init__.py
Expand Up @@ -38,6 +38,7 @@
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 = [
Expand Down Expand Up @@ -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,
}


Expand Down

0 comments on commit a12f09f

Please sign in to comment.