Fix LBaaS Haproxy occurs error if no member is added
If no member is added and session_persistence.type=HTTP_COOKIE, haproxy agent would not add cookie persistence option to the backend. Closes-Bug: #1302283 Change-Id: Ifa2564df924c2555225a749a99c705b3f1caab4a
This commit is contained in:
parent
a701f23807
commit
f1463640ba
@ -199,7 +199,8 @@ def _get_session_persistence(config):
|
||||
if persistence['type'] == constants.SESSION_PERSISTENCE_SOURCE_IP:
|
||||
opts.append('stick-table type ip size 10k')
|
||||
opts.append('stick on src')
|
||||
elif persistence['type'] == constants.SESSION_PERSISTENCE_HTTP_COOKIE:
|
||||
elif (persistence['type'] == constants.SESSION_PERSISTENCE_HTTP_COOKIE and
|
||||
config.get('members')):
|
||||
opts.append('cookie SRV insert indirect nocache')
|
||||
elif (persistence['type'] == constants.SESSION_PERSISTENCE_APP_COOKIE and
|
||||
persistence.get('cookie_name')):
|
||||
|
@ -178,7 +178,15 @@ class TestHaproxyCfg(base.BaseTestCase):
|
||||
self.assertEqual(cfg._get_session_persistence(config),
|
||||
['stick-table type ip size 10k', 'stick on src'])
|
||||
|
||||
config = {'vip': {'session_persistence': {'type': 'HTTP_COOKIE'}},
|
||||
'members': []}
|
||||
self.assertEqual([], cfg._get_session_persistence(config))
|
||||
|
||||
config = {'vip': {'session_persistence': {'type': 'HTTP_COOKIE'}}}
|
||||
self.assertEqual([], cfg._get_session_persistence(config))
|
||||
|
||||
config = {'vip': {'session_persistence': {'type': 'HTTP_COOKIE'}},
|
||||
'members': [{'id': 'member1_id'}]}
|
||||
self.assertEqual(cfg._get_session_persistence(config),
|
||||
['cookie SRV insert indirect nocache'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user