Added glance_request_timeout config option.
The glanceclient supports a timeout for http/https connections but this is not configurable in cinder. This patch adds a glance_request_timeout option to cinder.conf. If unset, None is applied thus allowing glanceclient to use its default value (600). Change-Id: Ic689ecb5d5ee8257964b341b5a7980d5733343dc Fixes: bug #1206992 Co-authored-by: Takahiro Shida <shida@intellilink.co.jp>
This commit is contained in:
parent
f2c91c9a3c
commit
e5a4c75229
|
@ -4,6 +4,7 @@
|
|||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
# Copyright 2012 Red Hat, Inc.
|
||||
# Copyright 2013 NTT corp.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -112,6 +113,11 @@ global_opts = [
|
|||
'this may improve data throughput, eg when high network '
|
||||
'bandwidth is available and you are using already '
|
||||
'compressed image formats such as qcow2 .'),
|
||||
cfg.IntOpt('glance_request_timeout',
|
||||
default=None,
|
||||
help='http/https timeout value for glance operations. If no '
|
||||
'value (None) is supplied here, the glanceclient default '
|
||||
'value is used.'),
|
||||
cfg.StrOpt('scheduler_topic',
|
||||
default='cinder-scheduler',
|
||||
help='the topic scheduler nodes listen on'),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2010 OpenStack LLC.
|
||||
# Copyright 2013 NTT corp.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
@ -72,6 +73,8 @@ def _create_glance_client(context, netloc, use_ssl,
|
|||
scheme = 'http'
|
||||
if CONF.auth_strategy == 'keystone':
|
||||
params['token'] = context.auth_token
|
||||
if CONF.glance_request_timeout is not None:
|
||||
params['timeout'] = CONF.glance_request_timeout
|
||||
endpoint = '%s://%s' % (scheme, netloc)
|
||||
return glanceclient.Client(str(version), endpoint, **params)
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
import datetime
|
||||
|
||||
import glanceclient.exc
|
||||
import glanceclient.v2.client
|
||||
from glanceclient.v2.client import Client as glanceclient_v2
|
||||
from oslo.config import cfg
|
||||
|
||||
|
@ -599,3 +600,63 @@ def _create_failing_glance_client(info):
|
|||
return {}
|
||||
|
||||
return MyGlanceStubClient()
|
||||
|
||||
|
||||
class TestGlanceImageServiceClient(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestGlanceImageServiceClient, self).setUp()
|
||||
self.context = context.RequestContext('fake', 'fake', auth_token=True)
|
||||
self.stubs.Set(glance.time, 'sleep', lambda s: None)
|
||||
|
||||
def test_create_glance_client(self):
|
||||
self.flags(auth_strategy='keystone')
|
||||
self.flags(glance_request_timeout=60)
|
||||
|
||||
class MyGlanceStubClient(object):
|
||||
def __init__(inst, version, *args, **kwargs):
|
||||
self.assertEqual('1', version)
|
||||
self.assertEqual("http://fake_host:9292", args[0])
|
||||
self.assertEqual(True, kwargs['token'])
|
||||
self.assertEqual(60, kwargs['timeout'])
|
||||
|
||||
self.stubs.Set(glance.glanceclient, 'Client', MyGlanceStubClient)
|
||||
client = glance._create_glance_client(self.context, 'fake_host:9292',
|
||||
False)
|
||||
self.assertTrue(isinstance(client, MyGlanceStubClient))
|
||||
|
||||
def test_create_glance_client_auth_strategy_is_not_keystone(self):
|
||||
self.flags(auth_strategy='noauth')
|
||||
self.flags(glance_request_timeout=60)
|
||||
|
||||
class MyGlanceStubClient(object):
|
||||
def __init__(inst, version, *args, **kwargs):
|
||||
self.assertEqual('1', version)
|
||||
self.assertEqual('http://fake_host:9292', args[0])
|
||||
self.assertFalse('token' in kwargs)
|
||||
self.assertEqual(60, kwargs['timeout'])
|
||||
|
||||
self.stubs.Set(glance.glanceclient, 'Client', MyGlanceStubClient)
|
||||
client = glance._create_glance_client(self.context, 'fake_host:9292',
|
||||
False)
|
||||
self.assertTrue(isinstance(client, MyGlanceStubClient))
|
||||
|
||||
def test_create_glance_client_glance_request_default_timeout(self):
|
||||
self.flags(auth_strategy='keystone')
|
||||
self.flags(glance_request_timeout=None)
|
||||
|
||||
class MyGlanceStubClient(object):
|
||||
def __init__(inst, version, *args, **kwargs):
|
||||
self.assertEqual("1", version)
|
||||
self.assertEqual("http://fake_host:9292", args[0])
|
||||
self.assertEqual(True, kwargs['token'])
|
||||
self.assertFalse('timeout' in kwargs)
|
||||
|
||||
self.stubs.Set(glance.glanceclient, 'Client', MyGlanceStubClient)
|
||||
client = glance._create_glance_client(self.context, 'fake_host:9292',
|
||||
False)
|
||||
self.assertTrue(isinstance(client, MyGlanceStubClient))
|
||||
|
||||
def tearDown(self):
|
||||
self.stubs.UnsetAll()
|
||||
super(TestGlanceImageServiceClient, self).tearDown()
|
||||
|
|
|
@ -75,6 +75,10 @@
|
|||
# image formats such as qcow2 .
|
||||
#glance_api_ssl_compression=false
|
||||
|
||||
# http/https timeout value for glance operations. If no value (None) is
|
||||
# supplied, the glanceclient default value is used.
|
||||
#glance_request_timeout=None
|
||||
|
||||
# the topic scheduler nodes listen on (string value)
|
||||
#scheduler_topic=cinder-scheduler
|
||||
|
||||
|
|
Loading…
Reference in New Issue