Merge "Allow provisioning without controllers" into stable/8.0
This commit is contained in:
commit
043fa47d93
|
@ -1127,7 +1127,6 @@ class CheckBeforeDeploymentTask(object):
|
|||
@classmethod
|
||||
def execute(cls, task):
|
||||
cls._check_nodes_are_online(task)
|
||||
cls._check_controllers_count(task)
|
||||
cls._check_disks(task)
|
||||
cls._check_ceph(task)
|
||||
cls._check_volumes(task)
|
||||
|
@ -1162,39 +1161,6 @@ class CheckBeforeDeploymentTask(object):
|
|||
' Remove them from environment '
|
||||
'and try again.'.format(node_names))
|
||||
|
||||
@classmethod
|
||||
def _check_controllers_count(cls, task):
|
||||
cluster = task.cluster
|
||||
min_controllers = objects.Release.get_min_controller_count(
|
||||
cluster.release)
|
||||
|
||||
controllers = objects.Cluster.get_nodes_by_role(
|
||||
task.cluster, 'controller')
|
||||
# we should make sure that cluster has at least one controller
|
||||
if len(controllers) < min_controllers:
|
||||
raise errors.NotEnoughControllers(
|
||||
"Not enough controllers, %s mode requires at least %s "
|
||||
"controller(s)" % (cluster.mode, min_controllers))
|
||||
|
||||
if cluster.status in (
|
||||
consts.CLUSTER_STATUSES.operational,
|
||||
consts.CLUSTER_STATUSES.error,
|
||||
consts.CLUSTER_STATUSES.update_error):
|
||||
# get a list of deployed controllers - which are going
|
||||
# don't to be changed
|
||||
deployed_controllers = filter(
|
||||
lambda node: all([
|
||||
node.pending_addition is False,
|
||||
node.pending_deletion is False]),
|
||||
controllers)
|
||||
|
||||
# we should fail in case of user remove all controllers and add
|
||||
# new in one task, since that's affect cluster's availability
|
||||
if not deployed_controllers:
|
||||
raise errors.NotEnoughControllers(
|
||||
"Not enough deployed controllers - deployed cluster "
|
||||
"requires at least 1 deployed controller.")
|
||||
|
||||
@classmethod
|
||||
def _check_disks(cls, task):
|
||||
try:
|
||||
|
|
|
@ -153,8 +153,10 @@ class TestClusterChanges(BaseIntegrationTest):
|
|||
self.env.create_node(
|
||||
cluster_id=cluster["id"],
|
||||
status="error",
|
||||
error_type="provision"
|
||||
error_type="provision",
|
||||
pending_roles=["controller"]
|
||||
)
|
||||
|
||||
supertask = self.env.launch_deployment()
|
||||
self.env.wait_error(supertask, 60)
|
||||
attributes_changes = self.db.query(ClusterChanges).filter_by(
|
||||
|
|
|
@ -1643,39 +1643,6 @@ class TestHandlers(BaseIntegrationTest):
|
|||
"Node '%s' has insufficient disk space" %
|
||||
node_db.human_readable_name)
|
||||
|
||||
# TODO(awoodward): Purge multinode
|
||||
def test_occurs_error_not_enough_controllers_for_multinode(self):
|
||||
self.env.create(
|
||||
release_kwargs={
|
||||
'modes': [consts.CLUSTER_MODES.multinode, ]
|
||||
},
|
||||
cluster_kwargs={
|
||||
'mode': consts.CLUSTER_MODES.multinode
|
||||
},
|
||||
nodes_kwargs=[
|
||||
{'roles': ['compute'], 'pending_addition': True}])
|
||||
|
||||
task = self.env.launch_deployment()
|
||||
|
||||
self.assertEqual(task.status, 'error')
|
||||
self.assertEqual(
|
||||
task.message,
|
||||
"Not enough controllers, multinode mode requires at least 1 "
|
||||
"controller(s)")
|
||||
|
||||
def test_occurs_error_not_enough_controllers_for_ha(self):
|
||||
self.env.create(
|
||||
nodes_kwargs=[
|
||||
{'roles': ['compute'], 'pending_addition': True}])
|
||||
|
||||
task = self.env.launch_deployment()
|
||||
|
||||
self.assertEqual(task.status, 'error')
|
||||
self.assertEqual(
|
||||
task.message,
|
||||
'Not enough controllers, ha_compact '
|
||||
'mode requires at least 1 controller(s)')
|
||||
|
||||
def test_occurs_error_not_enough_osds_for_ceph(self):
|
||||
cluster = self.env.create(
|
||||
nodes_kwargs=[
|
||||
|
@ -1857,3 +1824,15 @@ class TestHandlers(BaseIntegrationTest):
|
|||
)
|
||||
deploy_task = self.env.launch_deployment()
|
||||
self.assertEqual(consts.TASK_STATUSES.pending, deploy_task.status)
|
||||
|
||||
@fake_tasks()
|
||||
def test_deploymend_possible_without_controllers(self):
|
||||
cluster = self.env.create_cluster(api=True)
|
||||
self.env.create_node(
|
||||
cluster_id=cluster["id"],
|
||||
status=consts.NODE_STATUSES.discover,
|
||||
pending_roles=["compute"]
|
||||
)
|
||||
|
||||
supertask = self.env.launch_deployment()
|
||||
self.env.wait_ready(supertask, timeout=60)
|
||||
|
|
|
@ -368,36 +368,6 @@ class TestCheckBeforeDeploymentTask(BaseTestCase):
|
|||
|
||||
task.CheckBeforeDeploymentTask._check_nodes_are_online(self.task)
|
||||
|
||||
def test_check_controllers_count_operational_cluster(self):
|
||||
self.cluster.status = consts.CLUSTER_STATUSES.operational
|
||||
|
||||
# remove old controller and add new one
|
||||
self.node.pending_deletion = True
|
||||
new_controller = self.env.create_node()
|
||||
new_controller.pendint_addition = True
|
||||
|
||||
self.assertRaises(
|
||||
errors.NotEnoughControllers,
|
||||
task.CheckBeforeDeploymentTask._check_controllers_count,
|
||||
self.task)
|
||||
|
||||
def test_check_controllers_count_new_cluster(self):
|
||||
self.cluster.status = consts.CLUSTER_STATUSES.new
|
||||
|
||||
# check there's not exceptions with one controller
|
||||
self.assertNotRaises(
|
||||
errors.NotEnoughControllers,
|
||||
task.CheckBeforeDeploymentTask._check_controllers_count,
|
||||
self.task)
|
||||
|
||||
# check there's exception with one non-controller node
|
||||
self.node.roles = ['compute']
|
||||
self.env.db.flush()
|
||||
self.assertRaises(
|
||||
errors.NotEnoughControllers,
|
||||
task.CheckBeforeDeploymentTask._check_controllers_count,
|
||||
self.task)
|
||||
|
||||
def find_net_by_name(self, nets, name):
|
||||
for net in nets['networks']:
|
||||
if net['name'] == name:
|
||||
|
|
Loading…
Reference in New Issue