Bay_create_timeout should be set to 60 default

Bay_create_timeout default is 0 and means that magnum create bay
without timeout. But heat create stack with timeout absolutely.
So it is impossible to create bay without timeout. And I had send
a patch which allow heat to create stack without timeout, but the
core of heat did not agree with it.
The patch is: https://review.openstack.org/#/c/334138/

Change-Id: Iebc9915dcf2894a2dbed912244a2c7c308b4d9d7
Closes-bug: #1590636
This commit is contained in:
PanFengyun 2016-07-03 23:26:32 +08:00
parent 4d1d73b90e
commit f5150078ee
8 changed files with 21 additions and 19 deletions

View File

@ -427,7 +427,7 @@ redis-master is running::
| status_reason | Stack CREATE completed successfully |
| created_at | 2016-05-26T17:45:57+00:00 |
| updated_at | 2016-05-26T17:50:02+00:00 |
| bay_create_timeout | 0 |
| bay_create_timeout | 60 |
| api_address | https://172.24.4.4:6443 |
| baymodel_id | e73298e7-e621-4d42-b35b-7a1952b97158 |
| master_addresses | ['172.24.4.6'] |
@ -632,7 +632,7 @@ to make sure the bay's status is 'CREATE_COMPLETE'::
| status_reason | Stack CREATE completed successfully |
| created_at | 2015-06-09T20:21:43+00:00 |
| updated_at | 2015-06-09T20:28:18+00:00 |
| bay_create_timeout | 0 |
| bay_create_timeout | 60 |
| api_address | 172.24.4.115 |
| baymodel_id | 92dbda62-32d4-4435-88fc-8f42d514b347 |
| node_count | 2 |

View File

@ -96,7 +96,7 @@ Now create a bay. Use the baymodel name as a template for bay creation::
| status_reason | None |
| created_at | 2015-10-08T04:19:14+00:00 |
| updated_at | None |
| bay_create_timeout | 0 |
| bay_create_timeout | 60 |
| api_address | None |
| baymodel_id | da2825a0-6d09-4208-b39e-b2db666f1118 |
| node_count | 1 |
@ -117,7 +117,7 @@ Now run bay-show command to get the IP of the bay host::
| status_reason | Stack CREATE completed successfully |
| created_at | 2015-10-08T04:19:14+00:00 |
| updated_at | 2015-10-08T04:21:00+00:00 |
| bay_create_timeout | 0 |
| bay_create_timeout | 60 |
| api_address | https://192.168.19.86:6443 |
| baymodel_id | da2825a0-6d09-4208-b39e-b2db666f1118 |
| node_count | 1 |

View File

@ -96,8 +96,8 @@ class Bay(base.APIBase):
master_count = wsme.wsattr(wtypes.IntegerType(minimum=1), default=1)
"""The number of master nodes for this bay. Default to 1 if not set"""
bay_create_timeout = wsme.wsattr(wtypes.IntegerType(minimum=0), default=0)
"""Timeout for creating the bay in minutes. Default to 0 if not set"""
bay_create_timeout = wsme.wsattr(wtypes.IntegerType(minimum=0), default=60)
"""Timeout for creating the bay in minutes. Default to 60 if not set"""
links = wsme.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated bay links"""

View File

@ -52,8 +52,9 @@ bay_heat_opts = [
help=('Sleep time interval between two attempts of querying '
'the Heat stack. This interval is in seconds.')),
cfg.IntOpt('bay_create_timeout',
help=('The length of time to let bay creation continue. This '
'interval is in minutes. The default is no timeout.'))
default=60,
help=('The length of time to let bay creation continue. This '
'interval is in minutes. The default is 60 minutes.'))
]
CONF = cfg.CONF
@ -97,8 +98,6 @@ def _create_stack(context, osc, bay, bay_create_timeout):
stack_name = '%s-%s' % (bay.name, short_id.generate_id())
if bay_create_timeout:
heat_timeout = bay_create_timeout
elif bay_create_timeout == 0:
heat_timeout = None
else:
# no bay_create_timeout value was passed in to the request
# so falling back on configuration file value

View File

@ -18,6 +18,7 @@ Tests for `magnum` module.
"""
import os
from oslo_config import cfg
import subprocess
import tempfile
import time
@ -252,14 +253,16 @@ extendedKeyUsage = clientAuth
def setUp(self):
super(BayTest, self).setUp()
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 60)
try:
test_timeout = int(test_timeout)
except ValueError:
# If timeout value is invalid do not set a timeout.
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
# If timeout value is invalid, set a default timeout.
test_timeout = cfg.CONF.bay_heat.bay_create_timeout
if test_timeout <= 0:
test_timeout = cfg.CONF.bay_heat.bay_create_timeout
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
self.addOnException(
self.copy_logs_handler(

View File

@ -39,7 +39,7 @@ class TestBayObject(base.TestCase):
bay = api_bay.Bay(**bay_dict)
self.assertEqual(1, bay.node_count)
self.assertEqual(1, bay.master_count)
self.assertEqual(0, bay.bay_create_timeout)
self.assertEqual(60, bay.bay_create_timeout)
class TestListBay(api_base.FunctionalTest):
@ -562,7 +562,7 @@ class TestPost(api_base.FunctionalTest):
def test_create_bay_with_no_timeout(self):
def _simulate_rpc_bay_create(bay, bay_create_timeout):
self.assertEqual(0, bay_create_timeout)
self.assertEqual(60, bay_create_timeout)
bay.create()
return bay
self.mock_bay_create.side_effect = _simulate_rpc_bay_create

View File

@ -605,7 +605,7 @@ class TestBayConductorWithK8s(base.TestCase):
expected_template_contents = 'template_contents'
dummy_bay_name = 'expected_stack_name'
bay_timeout = 0
expected_timeout = None
expected_timeout = cfg.CONF.bay_heat.bay_create_timeout
mock_tpl_files = {}
mock_get_template_contents.return_value = [

View File

@ -86,7 +86,7 @@ def get_test_bay(**kw):
'stack_id': kw.get('stack_id', '047c6319-7abd-4bd9-a033-8c6af0173cd0'),
'status': kw.get('status', 'CREATE_IN_PROGRESS'),
'status_reason': kw.get('status_reason', 'Completed successfully'),
'bay_create_timeout': kw.get('bay_create_timeout', 0),
'bay_create_timeout': kw.get('bay_create_timeout', 60),
'api_address': kw.get('api_address', '172.17.2.3'),
'node_addresses': kw.get('node_addresses', ['172.17.2.4']),
'node_count': kw.get('node_count', 3),