diff options
author | Vladimir Kuklin <vkuklin@mirantis.com> | 2017-01-18 21:46:42 +0300 |
---|---|---|
committer | Georgy Kibardin <gkibardin@mirantis.com> | 2017-02-07 17:44:06 +0000 |
commit | cd2ee13830dbed7405cf5587c0fa30cf1f1f97fd (patch) | |
tree | d608ae5a6feef689f10954ce4b8daeb858bd7807 | |
parent | 3d6d48a233314679e266abf1dacbebebaa51025c (diff) |
Set nodes' statuses to 'error' when their nodegroup is deleted
According to the bug below and the spec, we did not implement
one multirack feature aspect.
https://specs.openstack.org/openstack/fuel-specs/specs/8.0/multi-rack-static.html#notifications-impact
Now we add resetting node to error to node group deletion callback and
send a notification.
Change-Id: I6b2bae5601ba7dbca620bb3861e95b0e554f8699
Closes-bug: #1644630
Notes
Notes (review):
Code-Review+1: Georgy Kibardin <gkibardin@mirantis.com>
Code-Review+1: Alexander Kislitsky <akislitsky@mirantis.com>
Code-Review+2: Aleksey Kasatkin <akasatkin@mirantis.com>
Code-Review+2: Bulat Gaifullin <gaifullinbf@gmail.com>
Verified+1: Fuel CI <fuel-ci-bot@mirantis.com>
Workflow+1: Aleksey Kasatkin <akasatkin@mirantis.com>
Verified+2: Jenkins
Submitted-by: Jenkins
Submitted-at: Thu, 09 Feb 2017 11:17:07 +0000
Reviewed-on: https://review.openstack.org/422166
Project: openstack/fuel-web
Branch: refs/heads/master
-rw-r--r-- | nailgun/nailgun/extensions/network_manager/extension.py | 12 | ||||
-rw-r--r-- | nailgun/nailgun/test/base.py | 4 | ||||
-rw-r--r-- | nailgun/nailgun/test/unit/test_node_groups.py | 39 |
3 files changed, 52 insertions, 3 deletions
diff --git a/nailgun/nailgun/extensions/network_manager/extension.py b/nailgun/nailgun/extensions/network_manager/extension.py index 2db6dda..502b27f 100644 --- a/nailgun/nailgun/extensions/network_manager/extension.py +++ b/nailgun/nailgun/extensions/network_manager/extension.py | |||
@@ -182,6 +182,18 @@ class NetworkManagerExtension(BaseExtension): | |||
182 | 182 | ||
183 | @classmethod | 183 | @classmethod |
184 | def on_nodegroup_delete(cls, ng): | 184 | def on_nodegroup_delete(cls, ng): |
185 | netmanager = objects.Cluster.get_network_manager(ng.cluster) | ||
186 | default_admin_net = objects.NetworkGroup.get_default_admin_network() | ||
187 | for node in ng.nodes: | ||
188 | objects.Node.remove_from_cluster(node) | ||
189 | if not netmanager.is_same_network(node.ip, default_admin_net.cidr): | ||
190 | objects.Node.set_error_status_and_file_notification( | ||
191 | node, | ||
192 | consts.NODE_ERRORS.discover, | ||
193 | "Node '{0}' nodegroup was deleted which means that it may " | ||
194 | "not be able to boot correctly unless it is a member of " | ||
195 | "another node group admin network".format(node.hostname) | ||
196 | ) | ||
185 | try: | 197 | try: |
186 | task = UpdateDnsmasqTaskManager().execute() | 198 | task = UpdateDnsmasqTaskManager().execute() |
187 | except errors.TaskAlreadyRunning: | 199 | except errors.TaskAlreadyRunning: |
diff --git a/nailgun/nailgun/test/base.py b/nailgun/nailgun/test/base.py index f3c2baa..68ed6f1 100644 --- a/nailgun/nailgun/test/base.py +++ b/nailgun/nailgun/test/base.py | |||
@@ -1452,7 +1452,7 @@ class EnvironmentManager(object): | |||
1452 | expect_errors) | 1452 | expect_errors) |
1453 | 1453 | ||
1454 | def _create_network_group(self, expect_errors=False, cluster=None, | 1454 | def _create_network_group(self, expect_errors=False, cluster=None, |
1455 | **kwargs): | 1455 | group_id=None, **kwargs): |
1456 | if not cluster: | 1456 | if not cluster: |
1457 | cluster = self.clusters[0] | 1457 | cluster = self.clusters[0] |
1458 | ng = { | 1458 | ng = { |
@@ -1461,7 +1461,7 @@ class EnvironmentManager(object): | |||
1461 | "vlan_start": 50, | 1461 | "vlan_start": 50, |
1462 | "cidr": "10.3.0.0/24", | 1462 | "cidr": "10.3.0.0/24", |
1463 | "gateway": "10.3.0.1", | 1463 | "gateway": "10.3.0.1", |
1464 | "group_id": Cluster.get_default_group(cluster).id, | 1464 | "group_id": group_id or Cluster.get_default_group(cluster).id, |
1465 | "meta": { | 1465 | "meta": { |
1466 | "notation": consts.NETWORK_NOTATION.cidr, | 1466 | "notation": consts.NETWORK_NOTATION.cidr, |
1467 | "use_gateway": True, | 1467 | "use_gateway": True, |
diff --git a/nailgun/nailgun/test/unit/test_node_groups.py b/nailgun/nailgun/test/unit/test_node_groups.py index cdd12ab..0893a36 100644 --- a/nailgun/nailgun/test/unit/test_node_groups.py +++ b/nailgun/nailgun/test/unit/test_node_groups.py | |||
@@ -26,6 +26,7 @@ from nailgun.db import db | |||
26 | from nailgun.db.sqlalchemy import models | 26 | from nailgun.db.sqlalchemy import models |
27 | from nailgun import errors | 27 | from nailgun import errors |
28 | from nailgun import objects | 28 | from nailgun import objects |
29 | from nailgun.rpc.receiver import NailgunReceiver | ||
29 | from nailgun.test.base import BaseIntegrationTest | 30 | from nailgun.test.base import BaseIntegrationTest |
30 | from nailgun.utils import reverse | 31 | from nailgun.utils import reverse |
31 | 32 | ||
@@ -37,7 +38,7 @@ class TestNodeGroups(BaseIntegrationTest): | |||
37 | def setUp(self): | 38 | def setUp(self): |
38 | super(TestNodeGroups, self).setUp() | 39 | super(TestNodeGroups, self).setUp() |
39 | self.cluster = self.env.create( | 40 | self.cluster = self.env.create( |
40 | release_kwargs={'version': '1111-8.0'}, | 41 | release_kwargs={'version': '1111-9.0'}, |
41 | cluster_kwargs={ | 42 | cluster_kwargs={ |
42 | 'api': False, | 43 | 'api': False, |
43 | 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron, | 44 | 'net_provider': consts.CLUSTER_NET_PROVIDERS.neutron, |
@@ -159,6 +160,42 @@ class TestNodeGroups(BaseIntegrationTest): | |||
159 | self.assertEqual(err.exception.message, | 160 | self.assertEqual(err.exception.message, |
160 | 'Default node group cannot be deleted.') | 161 | 'Default node group cannot be deleted.') |
161 | 162 | ||
163 | @patch('nailgun.task.task.rpc.cast') | ||
164 | @patch('objects.Notification.create') | ||
165 | def test_delete_non_default_node_group_reset_node_to_error( | ||
166 | self, _, notify): | ||
167 | node_group = self.env.create_node_group(api=False, | ||
168 | cluster_id=self.cluster.id) | ||
169 | self.env._create_network_group(cluster=self.cluster, | ||
170 | group_id=node_group.id) | ||
171 | node2 = self.env.create_node(group_id=node_group.id, | ||
172 | roles=['compute'], | ||
173 | status=consts.NODE_STATUSES.provisioned, | ||
174 | cluster_id=self.cluster.id, | ||
175 | ip='10.3.0.42') | ||
176 | task = self.env.launch_deployment() | ||
177 | NailgunReceiver.deploy_resp( | ||
178 | task_uuid=task.uuid, | ||
179 | status=consts.TASK_STATUSES.ready, | ||
180 | progress=100, | ||
181 | nodes=[{'uid': n.uid, 'status': consts.NODE_STATUSES.ready, | ||
182 | 'progress': 100} | ||
183 | for n in self.env.nodes], | ||
184 | ) | ||
185 | reset_task = self.env.reset_environment() | ||
186 | NailgunReceiver.reset_environment_resp( | ||
187 | task_uuid=reset_task.uuid, | ||
188 | status=consts.TASK_STATUSES.ready, | ||
189 | progress=100, | ||
190 | nodes=[{'uid': n.uid} | ||
191 | for n in self.env.nodes], | ||
192 | ) | ||
193 | self.env.delete_node_group(node_group.id) | ||
194 | self.assertEqual(node2.status, consts.NODE_STATUSES.error) | ||
195 | self.assertEqual(node2.error_type, consts.NODE_ERRORS.discover) | ||
196 | self.assertIsNone(node2.cluster) | ||
197 | notify.assert_called() | ||
198 | |||
162 | def test_delete_non_default_node_group_error(self): | 199 | def test_delete_non_default_node_group_error(self): |
163 | node_group = self.env.create_node_group(api=False, | 200 | node_group = self.env.create_node_group(api=False, |
164 | cluster_id=self.cluster.id) | 201 | cluster_id=self.cluster.id) |