Allow errored cluster to have settings unlocked
Is_locked method erroneously blocks errored cluster. This is a simple one-line change fix. Closes-bug: #1566330 Change-Id: Ia831b30528be2e904507cc5d2f8a5541d2a6cc01
This commit is contained in:
parent
74be5e6b50
commit
b9e911c2bc
|
@ -143,6 +143,7 @@ class Cluster(Base):
|
||||||
@property
|
@property
|
||||||
def is_locked(self):
|
def is_locked(self):
|
||||||
allowed_status = (
|
allowed_status = (
|
||||||
|
consts.CLUSTER_STATUSES.error,
|
||||||
consts.CLUSTER_STATUSES.new,
|
consts.CLUSTER_STATUSES.new,
|
||||||
consts.CLUSTER_STATUSES.operational,
|
consts.CLUSTER_STATUSES.operational,
|
||||||
consts.CLUSTER_STATUSES.stopped,
|
consts.CLUSTER_STATUSES.stopped,
|
||||||
|
|
|
@ -464,6 +464,7 @@ class TestAlwaysEditable(BaseIntegrationTest):
|
||||||
def test_can_change_repos_on_operational_cluster(self):
|
def test_can_change_repos_on_operational_cluster(self):
|
||||||
self.cluster.status = consts.CLUSTER_STATUSES.operational
|
self.cluster.status = consts.CLUSTER_STATUSES.operational
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
data = {'editable': {}}
|
data = {'editable': {}}
|
||||||
data['editable'].update(self._reposetup)
|
data['editable'].update(self._reposetup)
|
||||||
|
|
|
@ -57,6 +57,7 @@ class TestErrors(BaseIntegrationTest):
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
self.assertEqual(supertask.cluster.status, 'error')
|
self.assertEqual(supertask.cluster.status, 'error')
|
||||||
|
self.assertFalse(supertask.cluster.is_locked)
|
||||||
|
|
||||||
@fake_tasks(error="deployment", error_msg="Terrible error")
|
@fake_tasks(error="deployment", error_msg="Terrible error")
|
||||||
def test_deployment_error_from_orchestrator(self):
|
def test_deployment_error_from_orchestrator(self):
|
||||||
|
@ -93,6 +94,7 @@ class TestErrors(BaseIntegrationTest):
|
||||||
).first()
|
).first()
|
||||||
self.assertIsNotNone(err_notification)
|
self.assertIsNotNone(err_notification)
|
||||||
self.assertEqual(supertask.cluster.status, 'error')
|
self.assertEqual(supertask.cluster.status, 'error')
|
||||||
|
self.assertFalse(supertask.cluster.is_locked)
|
||||||
|
|
||||||
@fake_tasks(error="deployment")
|
@fake_tasks(error="deployment")
|
||||||
def test_deployment_error_during_deployment(self):
|
def test_deployment_error_during_deployment(self):
|
||||||
|
@ -117,6 +119,7 @@ class TestErrors(BaseIntegrationTest):
|
||||||
|
|
||||||
self.assertEqual(len(map(n_error, self.env.nodes)), 2)
|
self.assertEqual(len(map(n_error, self.env.nodes)), 2)
|
||||||
self.assertEqual(supertask.cluster.status, 'error')
|
self.assertEqual(supertask.cluster.status, 'error')
|
||||||
|
self.assertFalse(supertask.cluster.is_locked)
|
||||||
|
|
||||||
@fake_tasks(error="deployment", task_ready=True)
|
@fake_tasks(error="deployment", task_ready=True)
|
||||||
def test_task_ready_node_error(self):
|
def test_task_ready_node_error(self):
|
||||||
|
@ -136,3 +139,4 @@ class TestErrors(BaseIntegrationTest):
|
||||||
)
|
)
|
||||||
self.assertEqual(supertask.status, consts.TASK_STATUSES.error)
|
self.assertEqual(supertask.status, consts.TASK_STATUSES.error)
|
||||||
self.assertRegexpMatches(supertask.message, message)
|
self.assertRegexpMatches(supertask.message, message)
|
||||||
|
self.assertFalse(supertask.cluster.is_locked)
|
||||||
|
|
|
@ -92,6 +92,13 @@ class TestNetworkModels(BaseIntegrationTest):
|
||||||
headers=self.default_headers,
|
headers=self.default_headers,
|
||||||
expect_errors=True)
|
expect_errors=True)
|
||||||
|
|
||||||
|
resp_cluster_get = self.app.get(
|
||||||
|
reverse('ClusterHandler',
|
||||||
|
kwargs={'obj_id': self.env.clusters[0].id}),
|
||||||
|
headers=self.default_headers)
|
||||||
|
|
||||||
|
self.assertTrue(resp_cluster_get.json_body['is_locked'])
|
||||||
|
|
||||||
self.assertEqual(resp_nova_net.status_code, 400)
|
self.assertEqual(resp_nova_net.status_code, 400)
|
||||||
# it's 400 because we used Nova network
|
# it's 400 because we used Nova network
|
||||||
self.assertEqual(resp_neutron_net.status_code, 403)
|
self.assertEqual(resp_neutron_net.status_code, 403)
|
||||||
|
|
|
@ -75,6 +75,7 @@ class TestStopDeployment(BaseIntegrationTest):
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, consts.CLUSTER_STATUSES.stopped)
|
self.assertEqual(self.cluster.status, consts.CLUSTER_STATUSES.stopped)
|
||||||
self.assertEqual(stop_task.progress, 100)
|
self.assertEqual(stop_task.progress, 100)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
for n in self.cluster.nodes:
|
for n in self.cluster.nodes:
|
||||||
self.assertEqual(n.roles, [])
|
self.assertEqual(n.roles, [])
|
||||||
|
@ -198,6 +199,7 @@ class TestStopDeployment(BaseIntegrationTest):
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, consts.CLUSTER_STATUSES.stopped)
|
self.assertEqual(self.cluster.status, consts.CLUSTER_STATUSES.stopped)
|
||||||
self.assertEqual(stop_task.progress, 100)
|
self.assertEqual(stop_task.progress, 100)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
@patch('nailgun.rpc.cast')
|
@patch('nailgun.rpc.cast')
|
||||||
def test_latest_task_is_sent(self, mocked_rpc):
|
def test_latest_task_is_sent(self, mocked_rpc):
|
||||||
|
|
|
@ -841,6 +841,7 @@ class TestVerifyNeutronVlan(BaseIntegrationTest):
|
||||||
self.assertEqual(stop_task.status, consts.TASK_STATUSES.ready)
|
self.assertEqual(stop_task.status, consts.TASK_STATUSES.ready)
|
||||||
self.db.refresh(cluster)
|
self.db.refresh(cluster)
|
||||||
self.assertEqual(cluster.status, consts.CLUSTER_STATUSES.stopped)
|
self.assertEqual(cluster.status, consts.CLUSTER_STATUSES.stopped)
|
||||||
|
self.assertFalse(cluster.is_locked)
|
||||||
# Moving nodes online by hands. Our fake threads do this with
|
# Moving nodes online by hands. Our fake threads do this with
|
||||||
# random success
|
# random success
|
||||||
for node in sorted(cluster.nodes, key=lambda n: n.id):
|
for node in sorted(cluster.nodes, key=lambda n: n.id):
|
||||||
|
|
|
@ -713,6 +713,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
self._node_should_be_error_with_type(self.cluster.nodes[0],
|
self._node_should_be_error_with_type(self.cluster.nodes[0],
|
||||||
consts.NODE_ERRORS.deploy)
|
consts.NODE_ERRORS.deploy)
|
||||||
self._nodes_should_not_be_error(self.cluster.nodes[1:])
|
self._nodes_should_not_be_error(self.cluster.nodes[1:])
|
||||||
|
@ -728,6 +729,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
def test_update_nodes_to_error_if_provision_task_failed(self):
|
def test_update_nodes_to_error_if_provision_task_failed(self):
|
||||||
self.cluster.nodes[0].status = consts.NODE_STATUSES.provisioning
|
self.cluster.nodes[0].status = consts.NODE_STATUSES.provisioning
|
||||||
|
@ -742,6 +744,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
self._node_should_be_error_with_type(self.cluster.nodes[0],
|
self._node_should_be_error_with_type(self.cluster.nodes[0],
|
||||||
consts.NODE_ERRORS.provision)
|
consts.NODE_ERRORS.provision)
|
||||||
self._nodes_should_not_be_error(self.cluster.nodes[1:])
|
self._nodes_should_not_be_error(self.cluster.nodes[1:])
|
||||||
|
@ -761,6 +764,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status,
|
self.assertEqual(self.cluster.status,
|
||||||
consts.CLUSTER_STATUSES.operational)
|
consts.CLUSTER_STATUSES.operational)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
self.cluster.attributes.generated['deployed_before']['value'])
|
self.cluster.attributes.generated['deployed_before']['value'])
|
||||||
|
|
||||||
|
@ -803,6 +807,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status,
|
self.assertEquals(self.cluster.status,
|
||||||
consts.CLUSTER_STATUSES.operational)
|
consts.CLUSTER_STATUSES.operational)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
for node in self.cluster.nodes:
|
for node in self.cluster.nodes:
|
||||||
self.assertEquals(node.status, consts.NODE_STATUSES.ready)
|
self.assertEquals(node.status, consts.NODE_STATUSES.ready)
|
||||||
|
@ -825,6 +830,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.error)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
self.assertEquals(task.status, consts.TASK_STATUSES.error)
|
self.assertEquals(task.status, consts.TASK_STATUSES.error)
|
||||||
|
|
||||||
for node in self.cluster.nodes:
|
for node in self.cluster.nodes:
|
||||||
|
@ -852,6 +858,7 @@ class TestTaskObject(BaseIntegrationTest):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.new)
|
self.assertEquals(self.cluster.status, consts.CLUSTER_STATUSES.new)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
def test_get_task_by_uuid_returns_task(self):
|
def test_get_task_by_uuid_returns_task(self):
|
||||||
task = Task(name=consts.TASK_NAMES.deploy)
|
task = Task(name=consts.TASK_NAMES.deploy)
|
||||||
|
|
|
@ -165,6 +165,8 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, 'error')
|
self.assertEqual(self.cluster.status, 'error')
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
self.node_should_be_error_with_type(self.cluster.nodes[0], 'deploy')
|
self.node_should_be_error_with_type(self.cluster.nodes[0], 'deploy')
|
||||||
self.nodes_should_not_be_error(self.cluster.nodes[1:])
|
self.nodes_should_not_be_error(self.cluster.nodes[1:])
|
||||||
|
|
||||||
|
@ -177,6 +179,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, 'error')
|
self.assertEqual(self.cluster.status, 'error')
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
def test_update_nodes_to_error_if_provision_task_failed(self):
|
def test_update_nodes_to_error_if_provision_task_failed(self):
|
||||||
self.cluster.nodes[0].status = 'provisioning'
|
self.cluster.nodes[0].status = 'provisioning'
|
||||||
|
@ -190,6 +193,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, 'error')
|
self.assertEqual(self.cluster.status, 'error')
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
self.node_should_be_error_with_type(self.cluster.nodes[0], 'provision')
|
self.node_should_be_error_with_type(self.cluster.nodes[0], 'provision')
|
||||||
self.nodes_should_not_be_error(self.cluster.nodes[1:])
|
self.nodes_should_not_be_error(self.cluster.nodes[1:])
|
||||||
|
|
||||||
|
@ -208,6 +212,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.cluster.status, consts.CLUSTER_STATUSES.operational)
|
self.cluster.status, consts.CLUSTER_STATUSES.operational)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
def test_update_if_parent_task_is_ready_all_nodes_should_be_ready(self):
|
def test_update_if_parent_task_is_ready_all_nodes_should_be_ready(self):
|
||||||
for node in self.cluster.nodes:
|
for node in self.cluster.nodes:
|
||||||
|
@ -229,6 +234,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.cluster.status, consts.CLUSTER_STATUSES.operational)
|
self.cluster.status, consts.CLUSTER_STATUSES.operational)
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
for node in self.cluster.nodes:
|
for node in self.cluster.nodes:
|
||||||
self.assertEqual(node.status, consts.NODE_STATUSES.ready)
|
self.assertEqual(node.status, consts.NODE_STATUSES.ready)
|
||||||
|
@ -250,6 +256,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, 'error')
|
self.assertEqual(self.cluster.status, 'error')
|
||||||
self.assertEqual(provision_task.status, 'error')
|
self.assertEqual(provision_task.status, 'error')
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
for node in self.cluster.nodes:
|
for node in self.cluster.nodes:
|
||||||
self.assertEqual(node.status, 'error')
|
self.assertEqual(node.status, 'error')
|
||||||
|
@ -275,6 +282,7 @@ class TestHelperUpdateClusterStatus(BaseTestCase):
|
||||||
self.db.flush()
|
self.db.flush()
|
||||||
|
|
||||||
self.assertEqual(self.cluster.status, 'new')
|
self.assertEqual(self.cluster.status, 'new')
|
||||||
|
self.assertFalse(self.cluster.is_locked)
|
||||||
|
|
||||||
|
|
||||||
class TestCheckBeforeDeploymentTask(BaseTestCase):
|
class TestCheckBeforeDeploymentTask(BaseTestCase):
|
||||||
|
|
Loading…
Reference in New Issue