summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-05 12:50:20 +0000
committerGerrit Code Review <review@openstack.org>2018-10-05 12:50:20 +0000
commit8c663dbd25a0dab1c2d903efc7cf7fc3d9d07b00 (patch)
tree5efb591a2ca578c0ea19c2a467785eb07423663a
parente1faba1dfff96ca290559910c4eb93a9521fae93 (diff)
parentcbf3b7c70331fc2a7e7fcf3fa2551d806000b967 (diff)
Merge "Don't delete neutron port when attach failed" into stable/ocataocata-em15.1.5stable/ocata
-rw-r--r--doc/notification_samples/instance-shutdown-end.json15
-rw-r--r--nova/network/base_api.py1
-rw-r--r--nova/tests/unit/network/test_api.py24
-rw-r--r--releasenotes/notes/bug-1645175-b1ef3ad9a3e44ed6.yaml11
4 files changed, 31 insertions, 20 deletions
diff --git a/doc/notification_samples/instance-shutdown-end.json b/doc/notification_samples/instance-shutdown-end.json
index 2083b66..ccf01c0 100644
--- a/doc/notification_samples/instance-shutdown-end.json
+++ b/doc/notification_samples/instance-shutdown-end.json
@@ -11,20 +11,7 @@
11 "fault":null, 11 "fault":null,
12 "host":"compute", 12 "host":"compute",
13 "host_name":"some-server", 13 "host_name":"some-server",
14 "ip_addresses": [{ 14 "ip_addresses": [],
15 "nova_object.name": "IpPayload",
16 "nova_object.namespace": "nova",
17 "nova_object.version": "1.0",
18 "nova_object.data": {
19 "mac": "fa:16:3e:4c:2c:30",
20 "address": "192.168.1.3",
21 "port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
22 "meta": {},
23 "version": 4,
24 "label": "private-network",
25 "device_name": "tapce531f90-19"
26 }
27 }],
28 "kernel_id":"", 15 "kernel_id":"",
29 "launched_at":"2012-10-29T13:42:11Z", 16 "launched_at":"2012-10-29T13:42:11Z",
30 "image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6", 17 "image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
diff --git a/nova/network/base_api.py b/nova/network/base_api.py
index 3b6251c..f3167de 100644
--- a/nova/network/base_api.py
+++ b/nova/network/base_api.py
@@ -53,6 +53,7 @@ def update_instance_cache_with_nw_info(impl, context, instance,
53 ic = objects.InstanceInfoCache.new(context, instance.uuid) 53 ic = objects.InstanceInfoCache.new(context, instance.uuid)
54 ic.network_info = nw_info 54 ic.network_info = nw_info
55 ic.save(update_cells=update_cells) 55 ic.save(update_cells=update_cells)
56 instance.info_cache = ic
56 except Exception: 57 except Exception:
57 with excutils.save_and_reraise_exception(): 58 with excutils.save_and_reraise_exception():
58 LOG.exception(_LE('Failed storing info cache'), instance=instance) 59 LOG.exception(_LE('Failed storing info cache'), instance=instance)
diff --git a/nova/tests/unit/network/test_api.py b/nova/tests/unit/network/test_api.py
index 4765787..3fb0aad 100644
--- a/nova/tests/unit/network/test_api.py
+++ b/nova/tests/unit/network/test_api.py
@@ -15,6 +15,7 @@
15 15
16"""Tests for network API.""" 16"""Tests for network API."""
17 17
18import copy
18import itertools 19import itertools
19import uuid 20import uuid
20 21
@@ -559,7 +560,7 @@ class ApiTestCase(test.TestCase):
559 560
560 561
561@mock.patch('nova.network.api.API') 562@mock.patch('nova.network.api.API')
562@mock.patch('nova.db.instance_info_cache_update', return_value=fake_info_cache) 563@mock.patch('nova.db.instance_info_cache_update')
563class TestUpdateInstanceCache(test.NoDBTestCase): 564class TestUpdateInstanceCache(test.NoDBTestCase):
564 def setUp(self): 565 def setUp(self):
565 super(TestUpdateInstanceCache, self).setUp() 566 super(TestUpdateInstanceCache, self).setUp()
@@ -572,13 +573,16 @@ class TestUpdateInstanceCache(test.NoDBTestCase):
572 573
573 def test_update_nw_info_none(self, db_mock, api_mock): 574 def test_update_nw_info_none(self, db_mock, api_mock):
574 api_mock._get_instance_nw_info.return_value = self.nw_info 575 api_mock._get_instance_nw_info.return_value = self.nw_info
575 576 info_cache = copy.deepcopy(fake_info_cache)
577 info_cache.update({'network_info': self.nw_json})
578 db_mock.return_value = info_cache
576 base_api.update_instance_cache_with_nw_info(api_mock, self.context, 579 base_api.update_instance_cache_with_nw_info(api_mock, self.context,
577 self.instance, None) 580 self.instance, None)
578 api_mock._get_instance_nw_info.assert_called_once_with(self.context, 581 api_mock._get_instance_nw_info.assert_called_once_with(self.context,
579 self.instance) 582 self.instance)
580 db_mock.assert_called_once_with(self.context, self.instance.uuid, 583 db_mock.assert_called_once_with(self.context, self.instance.uuid,
581 {'network_info': self.nw_json}) 584 {'network_info': self.nw_json})
585 self.assertEqual(self.nw_info, self.instance.info_cache.network_info)
582 586
583 def test_update_nw_info_none_instance_deleted(self, db_mock, api_mock): 587 def test_update_nw_info_none_instance_deleted(self, db_mock, api_mock):
584 instance = objects.Instance(uuid=FAKE_UUID, deleted=True) 588 instance = objects.Instance(uuid=FAKE_UUID, deleted=True)
@@ -587,23 +591,29 @@ class TestUpdateInstanceCache(test.NoDBTestCase):
587 self.assertFalse(api_mock.called) 591 self.assertFalse(api_mock.called)
588 592
589 def test_update_nw_info_one_network(self, db_mock, api_mock): 593 def test_update_nw_info_one_network(self, db_mock, api_mock):
590 api_mock._get_instance_nw_info.return_value = self.nw_info 594 info_cache = copy.deepcopy(fake_info_cache)
595 info_cache.update({'network_info': self.nw_json})
596 db_mock.return_value = info_cache
591 base_api.update_instance_cache_with_nw_info(api_mock, self.context, 597 base_api.update_instance_cache_with_nw_info(api_mock, self.context,
592 self.instance, self.nw_info) 598 self.instance, self.nw_info)
593 self.assertFalse(api_mock._get_instance_nw_info.called) 599 self.assertFalse(api_mock._get_instance_nw_info.called)
594 db_mock.assert_called_once_with(self.context, self.instance.uuid, 600 db_mock.assert_called_once_with(self.context, self.instance.uuid,
595 {'network_info': self.nw_json}) 601 {'network_info': self.nw_json})
602 self.assertEqual(self.nw_info, self.instance.info_cache.network_info)
596 603
597 def test_update_nw_info_empty_list(self, db_mock, api_mock): 604 def test_update_nw_info_empty_list(self, db_mock, api_mock):
598 api_mock._get_instance_nw_info.return_value = self.nw_info 605 new_nw_info = network_model.NetworkInfo([])
606 db_mock.return_value = fake_info_cache
599 base_api.update_instance_cache_with_nw_info(api_mock, self.context, 607 base_api.update_instance_cache_with_nw_info(api_mock, self.context,
600 self.instance, 608 self.instance, new_nw_info)
601 network_model.NetworkInfo([]))
602 self.assertFalse(api_mock._get_instance_nw_info.called) 609 self.assertFalse(api_mock._get_instance_nw_info.called)
603 db_mock.assert_called_once_with(self.context, self.instance.uuid, 610 db_mock.assert_called_once_with(self.context, self.instance.uuid,
604 {'network_info': '[]'}) 611 {'network_info': '[]'})
612 self.assertEqual(new_nw_info, self.instance.info_cache.network_info)
605 613
606 def test_decorator_return_object(self, db_mock, api_mock): 614 def test_decorator_return_object(self, db_mock, api_mock):
615 db_mock.return_value = fake_info_cache
616
607 @base_api.refresh_cache 617 @base_api.refresh_cache
608 def func(self, context, instance): 618 def func(self, context, instance):
609 return network_model.NetworkInfo([]) 619 return network_model.NetworkInfo([])
@@ -613,6 +623,8 @@ class TestUpdateInstanceCache(test.NoDBTestCase):
613 {'network_info': '[]'}) 623 {'network_info': '[]'})
614 624
615 def test_decorator_return_none(self, db_mock, api_mock): 625 def test_decorator_return_none(self, db_mock, api_mock):
626 db_mock.return_value = fake_info_cache
627
616 @base_api.refresh_cache 628 @base_api.refresh_cache
617 def func(self, context, instance): 629 def func(self, context, instance):
618 pass 630 pass
diff --git a/releasenotes/notes/bug-1645175-b1ef3ad9a3e44ed6.yaml b/releasenotes/notes/bug-1645175-b1ef3ad9a3e44ed6.yaml
new file mode 100644
index 0000000..f5453bc
--- /dev/null
+++ b/releasenotes/notes/bug-1645175-b1ef3ad9a3e44ed6.yaml
@@ -0,0 +1,11 @@
1---
2other:
3 - |
4 ``instance.shutdown.end`` versioned notification will
5 have an empty ``ip_addresses`` field since the network
6 resources associated with the instance are deallocated
7 before this notification is sent, which is actually
8 more accurate. Consumers should rely on the
9 instance.shutdown.start notification if they need the
10 network information for the instance when it is being
11 deleted.