Don't lock settings if cluster is new
and before deployment validation failed * not set cluster status to error if before deployment validation tasks failed and cluster is new * move assignment of 'deployment' status after all data searilization and before deployment validation Closes-bug: #1263935 Change-Id: I1e4690380959897b91c4abe847e4c8672343884e
This commit is contained in:
parent
da98419023
commit
b294280f74
@ -243,7 +243,11 @@ class TaskHelper(object):
|
|||||||
|
|
||||||
cls.__set_cluster_status(cluster, 'operational')
|
cls.__set_cluster_status(cluster, 'operational')
|
||||||
cluster.clear_pending_changes()
|
cluster.clear_pending_changes()
|
||||||
elif task.status == 'error':
|
elif task.status == 'error' and \
|
||||||
|
not cls.__before_deployment_error(task):
|
||||||
|
# We don't want to set cluster status to
|
||||||
|
# error because we don't want to lock
|
||||||
|
# settings if cluster wasn't delpoyed
|
||||||
cls.__set_cluster_status(cluster, 'error')
|
cls.__set_cluster_status(cluster, 'error')
|
||||||
elif task.name == 'deployment' and task.status == 'error':
|
elif task.name == 'deployment' and task.status == 'error':
|
||||||
cls.__update_cluster_to_deployment_error(cluster)
|
cls.__update_cluster_to_deployment_error(cluster)
|
||||||
@ -252,6 +256,20 @@ class TaskHelper(object):
|
|||||||
|
|
||||||
db().commit()
|
db().commit()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __before_deployment_error(cls, task):
|
||||||
|
"""Returns True in case of check_before_deployment
|
||||||
|
or check_networks error and if cluster wasn't
|
||||||
|
deployed yet
|
||||||
|
"""
|
||||||
|
error_checking_tasks_count = db().query(Task).\
|
||||||
|
filter_by(parent_id=task.id).\
|
||||||
|
filter_by(status='error').\
|
||||||
|
filter(Task.name.in_(
|
||||||
|
['check_before_deployment', 'check_networks'])).count()
|
||||||
|
|
||||||
|
return task.cluster.status == 'new' and error_checking_tasks_count
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __update_cluster_to_provisioning_error(cls, cluster):
|
def __update_cluster_to_provisioning_error(cls, cluster):
|
||||||
cls.__set_cluster_status(cluster, 'error')
|
cls.__set_cluster_status(cluster, 'error')
|
||||||
|
@ -98,10 +98,6 @@ class ApplyChangesTaskManager(TaskManager):
|
|||||||
if not any([nodes_to_provision, nodes_to_deploy, nodes_to_delete]):
|
if not any([nodes_to_provision, nodes_to_deploy, nodes_to_delete]):
|
||||||
raise errors.WrongNodeStatus("No changes to deploy")
|
raise errors.WrongNodeStatus("No changes to deploy")
|
||||||
|
|
||||||
self.cluster.status = 'deployment'
|
|
||||||
db().add(self.cluster)
|
|
||||||
db().commit()
|
|
||||||
|
|
||||||
supertask = Task(name='deploy', cluster=self.cluster)
|
supertask = Task(name='deploy', cluster=self.cluster)
|
||||||
db().add(supertask)
|
db().add(supertask)
|
||||||
db().commit()
|
db().commit()
|
||||||
@ -196,6 +192,10 @@ class ApplyChangesTaskManager(TaskManager):
|
|||||||
node.status = 'provisioning'
|
node.status = 'provisioning'
|
||||||
db().commit()
|
db().commit()
|
||||||
|
|
||||||
|
self.cluster.status = 'deployment'
|
||||||
|
db().add(self.cluster)
|
||||||
|
db().commit()
|
||||||
|
|
||||||
if task_messages:
|
if task_messages:
|
||||||
rpc.cast('naily', task_messages)
|
rpc.cast('naily', task_messages)
|
||||||
|
|
||||||
|
@ -129,6 +129,25 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
|||||||
self.assertEquals(node.status, 'error')
|
self.assertEquals(node.status, 'error')
|
||||||
self.assertEquals(node.progress, 0)
|
self.assertEquals(node.progress, 0)
|
||||||
|
|
||||||
|
def test_do_not_set_cluster_to_error_if_validation_failed(self):
|
||||||
|
for task_name in ['check_before_deployment', 'check_networks']:
|
||||||
|
supertask = Task(
|
||||||
|
name='deploy',
|
||||||
|
cluster=self.cluster,
|
||||||
|
status='error')
|
||||||
|
|
||||||
|
check_task = Task(
|
||||||
|
name=task_name,
|
||||||
|
cluster=self.cluster,
|
||||||
|
status='error')
|
||||||
|
|
||||||
|
supertask.subtasks.append(check_task)
|
||||||
|
self.db.add(check_task)
|
||||||
|
self.db.commit()
|
||||||
|
|
||||||
|
TaskHelper.update_cluster_status(supertask.uuid)
|
||||||
|
self.assertEquals(self.cluster.status, 'new')
|
||||||
|
|
||||||
|
|
||||||
class TestCheckBeforeDeploymentTask(BaseTestCase):
|
class TestCheckBeforeDeploymentTask(BaseTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user