Merge "Take into account nodes which require redeployment"
This commit is contained in:
commit
0c53b2a744
@ -810,11 +810,19 @@ class CheckBeforeDeploymentTask(object):
|
||||
offline_nodes = db().query(Node).\
|
||||
filter(Node.cluster == task.cluster).\
|
||||
filter_by(online=False).\
|
||||
filter_by(pending_deletion=False).\
|
||||
filter(not_(Node.status.in_(['ready'])))
|
||||
filter_by(pending_deletion=False)
|
||||
|
||||
if offline_nodes.count():
|
||||
node_names = ','.join(map(lambda n: n.full_name, offline_nodes))
|
||||
offline_nodes_not_ready = [n for n in offline_nodes
|
||||
if n.status != consts.NODE_STATUSES.ready]
|
||||
nodes_to_deploy = TaskHelper.nodes_to_deploy(task.cluster)
|
||||
offline_nodes_to_redeploy = [
|
||||
n for n in offline_nodes
|
||||
if n.status == consts.NODE_STATUSES.ready and n in nodes_to_deploy]
|
||||
|
||||
if offline_nodes_not_ready or offline_nodes_to_redeploy:
|
||||
node_names = ','.join(
|
||||
map(lambda n: n.full_name,
|
||||
offline_nodes_not_ready + offline_nodes_to_redeploy))
|
||||
raise errors.NodeOffline(
|
||||
u'Nodes "{0}" are offline.'
|
||||
' Remove them from environment '
|
||||
|
@ -275,6 +275,34 @@ class TestTaskManagers(BaseIntegrationTest):
|
||||
# validation failed
|
||||
self.assertEqual(self.env.clusters[0].status, 'new')
|
||||
|
||||
@fake_tasks()
|
||||
def test_deployment_fails_if_node_to_redeploy_is_offline(self):
|
||||
cluster = self.env.create_cluster(
|
||||
api=True,
|
||||
status=consts.CLUSTER_STATUSES.operational)
|
||||
offline_node = self.env.create_node(
|
||||
cluster_id=cluster['id'],
|
||||
roles=["controller"],
|
||||
online=False,
|
||||
name="Offline node to be redeployed",
|
||||
status=consts.NODE_STATUSES.ready)
|
||||
self.env.create_node(
|
||||
cluster_id=cluster['id'],
|
||||
roles=["controller"],
|
||||
pending_addition=True)
|
||||
self.env.create_node(
|
||||
cluster_id=cluster['id'],
|
||||
roles=["compute"],
|
||||
pending_addition=True)
|
||||
supertask = self.env.launch_deployment()
|
||||
self.env.wait_error(
|
||||
supertask,
|
||||
5,
|
||||
'Nodes "{0}" are offline. Remove them from environment '
|
||||
'and try again.'.format(offline_node.full_name)
|
||||
)
|
||||
self.assertEqual(self.env.clusters[0].status, 'error')
|
||||
|
||||
@fake_tasks(override_state={"progress": 100, "status": "ready"})
|
||||
def test_redeployment_works(self):
|
||||
self.env.create(
|
||||
|
Loading…
Reference in New Issue
Block a user