From 79ac6df793d0c47de98f6b3a57026aef6bdbb1f3 Mon Sep 17 00:00:00 2001 From: aticig Date: Fri, 6 May 2022 16:09:52 +0300 Subject: [PATCH] Fix Bug 2022: RO updating VIM details with null info when VM is in error state This patch prevents to override the vim_details when VM is in error state. By this way, vim_details could be used for healing operations. The messages regarding with the failure is kept in another key names "vim_message". Change-Id: Ie0b73040074865a89d9ab2d447e20a8f3d38d520 Signed-off-by: aticig --- NG-RO/osm_ng_ro/ns.py | 3 +- NG-RO/osm_ng_ro/ns_thread.py | 95 +++++++++++-------- NG-RO/osm_ng_ro/tests/test_ns.py | 1 + NG-RO/osm_ng_ro/tests/test_ns_thread.py | 16 +++- .../notes/Fix_bug_2022-5e7655a0e8227c36.yaml | 22 +++++ 5 files changed, 91 insertions(+), 46 deletions(-) create mode 100644 releasenotes/notes/Fix_bug_2022-5e7655a0e8227c36.yaml diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 3bbb207f..c9791895 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -508,6 +508,7 @@ class Ns(object): "vim_name": None, "vim_status": None, "vim_details": None, + "vim_message": None, "refresh_at": None, }, "modified_at": now, @@ -2280,7 +2281,7 @@ class Ns(object): error_text = "Error at {} {}: {}".format( task["action"].lower(), task["item"], - ro_task["vim_info"].get("vim_details") or "unknown", + ro_task["vim_info"].get("vim_message") or "unknown", ) details.append(error_text) elif task["status"] in ("SCHEDULED", "BUILD"): diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 2950aa9b..d728d702 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -210,6 +210,7 @@ class VimInteractionNet(VimInteractionBase): "created": created, "created_items": created_items, "vim_details": None, + "vim_message": None, } self.logger.debug( "task={} {} new-net={} created={}".format( @@ -225,7 +226,7 @@ class VimInteractionNet(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -265,11 +266,11 @@ class VimInteractionNet(VimInteractionBase): ro_vim_item_update["vim_name"] = vim_info.get("name") if vim_info["status"] in ("ERROR", "VIM_ERROR"): - if ro_task["vim_info"]["vim_details"] != vim_info.get("error_msg"): - ro_vim_item_update["vim_details"] = vim_info.get("error_msg") + if ro_task["vim_info"]["vim_message"] != vim_info.get("error_msg"): + ro_vim_item_update["vim_message"] = vim_info.get("error_msg") elif vim_info["status"] == "DELETED": ro_vim_item_update["vim_id"] = None - ro_vim_item_update["vim_details"] = "Deleted externally" + ro_vim_item_update["vim_message"] = "Deleted externally" else: if ro_task["vim_info"]["vim_details"] != vim_info["vim_info"]: ro_vim_item_update["vim_details"] = vim_info["vim_info"] @@ -281,7 +282,7 @@ class VimInteractionNet(VimInteractionBase): ro_task["target_id"], vim_id, ro_vim_item_update.get("vim_status"), - ro_vim_item_update.get("vim_details") + ro_vim_item_update.get("vim_message") if ro_vim_item_update.get("vim_status") != "ACTIVE" else "", ) @@ -296,7 +297,7 @@ class VimInteractionNet(VimInteractionBase): ro_vim_item_update_ok = { "vim_status": "DELETED", "created": False, - "vim_details": "DELETED", + "vim_message": "DELETED", "vim_id": None, } @@ -307,7 +308,7 @@ class VimInteractionNet(VimInteractionBase): net_vim_id, ro_task["vim_info"]["created_items"] ) except vimconn.VimConnNotFoundException: - ro_vim_item_update_ok["vim_details"] = "already deleted" + ro_vim_item_update_ok["vim_message"] = "already deleted" except vimconn.VimConnException as e: self.logger.error( "ro_task={} vim={} del-net={}: {}".format( @@ -316,7 +317,7 @@ class VimInteractionNet(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "vim_details": "Error while deleting: {}".format(e), + "vim_message": "Error while deleting: {}".format(e), } return "FAILED", ro_vim_item_update @@ -326,7 +327,7 @@ class VimInteractionNet(VimInteractionBase): task_id, ro_task["target_id"], net_vim_id, - ro_vim_item_update_ok.get("vim_details", ""), + ro_vim_item_update_ok.get("vim_message", ""), ) ) @@ -395,6 +396,7 @@ class VimInteractionVdu(VimInteractionBase): "created": created, "created_items": created_items, "vim_details": None, + "vim_message": None, "interfaces_vim_ids": interfaces, "interfaces": [], } @@ -412,7 +414,7 @@ class VimInteractionVdu(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -424,7 +426,7 @@ class VimInteractionVdu(VimInteractionBase): ro_vim_item_update_ok = { "vim_status": "DELETED", "created": False, - "vim_details": "DELETED", + "vim_message": "DELETED", "vim_id": None, } @@ -442,7 +444,7 @@ class VimInteractionVdu(VimInteractionBase): ro_task["vim_info"].get("volumes_to_hold", []), ) except vimconn.VimConnNotFoundException: - ro_vim_item_update_ok["vim_details"] = "already deleted" + ro_vim_item_update_ok["vim_message"] = "already deleted" except vimconn.VimConnException as e: self.logger.error( "ro_task={} vim={} del-vm={}: {}".format( @@ -451,7 +453,7 @@ class VimInteractionVdu(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "vim_details": "Error while deleting: {}".format(e), + "vim_message": "Error while deleting: {}".format(e), } return "FAILED", ro_vim_item_update @@ -461,7 +463,7 @@ class VimInteractionVdu(VimInteractionBase): task_id, ro_task["target_id"], vm_vim_id, - ro_vim_item_update_ok.get("vim_details", ""), + ro_vim_item_update_ok.get("vim_message", ""), ) ) @@ -549,11 +551,11 @@ class VimInteractionVdu(VimInteractionBase): ro_vim_item_update["vim_name"] = vim_info.get("name") if vim_info["status"] in ("ERROR", "VIM_ERROR"): - if ro_task["vim_info"]["vim_details"] != vim_info.get("error_msg"): - ro_vim_item_update["vim_details"] = vim_info.get("error_msg") + if ro_task["vim_info"]["vim_message"] != vim_info.get("error_msg"): + ro_vim_item_update["vim_message"] = vim_info.get("error_msg") elif vim_info["status"] == "DELETED": ro_vim_item_update["vim_id"] = None - ro_vim_item_update["vim_details"] = "Deleted externally" + ro_vim_item_update["vim_message"] = "Deleted externally" else: if ro_task["vim_info"]["vim_details"] != vim_info["vim_info"]: ro_vim_item_update["vim_details"] = vim_info["vim_info"] @@ -565,7 +567,7 @@ class VimInteractionVdu(VimInteractionBase): ro_task["target_id"], vim_id, ro_vim_item_update.get("vim_status"), - ro_vim_item_update.get("vim_details") + ro_vim_item_update.get("vim_message") if ro_vim_item_update.get("vim_status") != "ACTIVE" else "", ) @@ -615,7 +617,7 @@ class VimInteractionVdu(VimInteractionBase): self.logger.error( "task={} {} inject-ssh-key: {}".format(task_id, ro_task["target_id"], e) ) - ro_vim_item_update = {"vim_details": str(e)} + ro_vim_item_update = {"vim_message": str(e)} return "FAILED", ro_vim_item_update, db_task_update @@ -654,6 +656,7 @@ class VimInteractionImage(VimInteractionBase): "created": created, "created_items": created_items, "vim_details": None, + "vim_message": None, } self.logger.debug( "task={} {} new-image={} created={}".format( @@ -669,7 +672,7 @@ class VimInteractionImage(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -683,7 +686,7 @@ class VimInteractionFlavor(VimInteractionBase): ro_vim_item_update_ok = { "vim_status": "DELETED", "created": False, - "vim_details": "DELETED", + "vim_message": "DELETED", "vim_id": None, } @@ -692,7 +695,7 @@ class VimInteractionFlavor(VimInteractionBase): target_vim = self.my_vims[ro_task["target_id"]] target_vim.delete_flavor(flavor_vim_id) except vimconn.VimConnNotFoundException: - ro_vim_item_update_ok["vim_details"] = "already deleted" + ro_vim_item_update_ok["vim_message"] = "already deleted" except vimconn.VimConnException as e: self.logger.error( "ro_task={} vim={} del-flavor={}: {}".format( @@ -701,7 +704,7 @@ class VimInteractionFlavor(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "vim_details": "Error while deleting: {}".format(e), + "vim_message": "Error while deleting: {}".format(e), } return "FAILED", ro_vim_item_update @@ -711,7 +714,7 @@ class VimInteractionFlavor(VimInteractionBase): task_id, ro_task["target_id"], flavor_vim_id, - ro_vim_item_update_ok.get("vim_details", ""), + ro_vim_item_update_ok.get("vim_message", ""), ) ) @@ -747,6 +750,7 @@ class VimInteractionFlavor(VimInteractionBase): "created": created, "created_items": created_items, "vim_details": None, + "vim_message": None, } self.logger.debug( "task={} {} new-flavor={} created={}".format( @@ -762,7 +766,7 @@ class VimInteractionFlavor(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -776,7 +780,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): ro_vim_item_update_ok = { "vim_status": "DELETED", "created": False, - "vim_details": "DELETED", + "vim_message": "DELETED", "vim_id": None, } @@ -785,7 +789,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): target_vim = self.my_vims[ro_task["target_id"]] target_vim.delete_affinity_group(affinity_group_vim_id) except vimconn.VimConnNotFoundException: - ro_vim_item_update_ok["vim_details"] = "already deleted" + ro_vim_item_update_ok["vim_message"] = "already deleted" except vimconn.VimConnException as e: self.logger.error( "ro_task={} vim={} del-affinity-or-anti-affinity-group={}: {}".format( @@ -794,7 +798,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "vim_details": "Error while deleting: {}".format(e), + "vim_message": "Error while deleting: {}".format(e), } return "FAILED", ro_vim_item_update @@ -804,7 +808,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): task_id, ro_task["target_id"], affinity_group_vim_id, - ro_vim_item_update_ok.get("vim_details", ""), + ro_vim_item_update_ok.get("vim_message", ""), ) ) @@ -852,6 +856,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): "created": created, "created_items": created_items, "vim_details": None, + "vim_message": None, } self.logger.debug( "task={} {} new-affinity-or-anti-affinity-group={} created={}".format( @@ -868,7 +873,7 @@ class VimInteractionAffinityGroup(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -1194,6 +1199,7 @@ class VimInteractionSdnNet(VimInteractionBase): "created_items": created_items, "connected_ports": connected_ports, "vim_details": sdn_info, + "vim_message": None, "last_update": last_update, } @@ -1208,7 +1214,7 @@ class VimInteractionSdnNet(VimInteractionBase): ro_vim_item_update = { "vim_status": "VIM_ERROR", "created": created, - "vim_details": str(e), + "vim_message": str(e), } return "FAILED", ro_vim_item_update @@ -1220,7 +1226,7 @@ class VimInteractionSdnNet(VimInteractionBase): ro_vim_item_update_ok = { "vim_status": "DELETED", "created": False, - "vim_details": "DELETED", + "vim_message": "DELETED", "vim_id": None, } @@ -1236,7 +1242,7 @@ class VimInteractionSdnNet(VimInteractionBase): isinstance(e, sdnconn.SdnConnectorError) and e.http_code == HTTPStatus.NOT_FOUND.value ): - ro_vim_item_update_ok["vim_details"] = "already deleted" + ro_vim_item_update_ok["vim_message"] = "already deleted" else: self.logger.error( "ro_task={} vim={} del-sdn-net={}: {}".format( @@ -1248,7 +1254,7 @@ class VimInteractionSdnNet(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "vim_details": "Error while deleting: {}".format(e), + "vim_message": "Error while deleting: {}".format(e), } return "FAILED", ro_vim_item_update @@ -1258,7 +1264,7 @@ class VimInteractionSdnNet(VimInteractionBase): task_id, ro_task["target_id"], sdn_vim_id, - ro_vim_item_update_ok.get("vim_details", ""), + ro_vim_item_update_ok.get("vim_message", ""), ) ) @@ -1729,7 +1735,7 @@ class NsWorker(threading.Thread): 1642158640.7986135;1642158640.7986135;1642158640.7986135;b134c9494e75:0a ;vim:b7ff9e24-8868-4d68-8a57-a59dc11d0327;None;{'created': False, 'created_items': None, 'vim_id': None, 'vim_name': None, 'vim_status': None, - 'vim_details': None, 'refresh_at': None};1;SCHEDULED; + 'vim_details': None, 'vim_message': None, 'refresh_at': None};1;SCHEDULED; 888f1864-749a-4fc2-bc1a-97c0fffd6a6f;0;888f1864-749a-4fc2-bc1a-97c0fffd6a6f:2; CREATE;image;{'filter_dict': {'name': 'ubuntu-os-cloud:image-family:ubuntu-1804-lts'}} """ @@ -1864,7 +1870,7 @@ class NsWorker(threading.Thread): exc_info=True, ) - return "FAILED", {"vim_status": "VIM_ERROR", "vim_details": str(e)} + return "FAILED", {"vim_status": "VIM_ERROR", "vim_message": str(e)} def _create_task(self, ro_task, task_index, task_depends, db_update): """ @@ -1902,7 +1908,7 @@ class NsWorker(threading.Thread): ) task_status = "FAILED" - ro_vim_item_update = {"vim_status": "VIM_ERROR", "vim_details": str(e)} + ro_vim_item_update = {"vim_status": "VIM_ERROR", "vim_message": str(e)} # TODO update ro_vim_item_update return task_status, ro_vim_item_update @@ -2081,7 +2087,7 @@ class NsWorker(threading.Thread): dependency_task["item"], dependency_task_id, dependency_ro_task["vim_info"].get( - "vim_details" + "vim_message" ), ) self.logger.error( @@ -2177,7 +2183,7 @@ class NsWorker(threading.Thread): new_status = "FAILED" db_vim_info_update = { "vim_status": "VIM_ERROR", - "vim_details": str(e), + "vim_message": str(e), } if not isinstance( @@ -2311,7 +2317,14 @@ class NsWorker(threading.Thread): path_vim_status + "." + k: v for k, v in ro_vim_item_update.items() if k - in ("vim_id", "vim_details", "vim_name", "vim_status", "interfaces") + in ( + "vim_id", + "vim_details", + "vim_message", + "vim_name", + "vim_status", + "interfaces", + ) } if path_vim_status.startswith("vdur."): diff --git a/NG-RO/osm_ng_ro/tests/test_ns.py b/NG-RO/osm_ng_ro/tests/test_ns.py index 8c900b09..4e081afa 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns.py +++ b/NG-RO/osm_ng_ro/tests/test_ns.py @@ -130,6 +130,7 @@ class TestNs(unittest.TestCase): "vim_name": None, "vim_status": None, "vim_details": None, + "vim_message": None, "refresh_at": None, }, "modified_at": now, diff --git a/NG-RO/osm_ng_ro/tests/test_ns_thread.py b/NG-RO/osm_ng_ro/tests/test_ns_thread.py index 63b10669..86a9dcd6 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns_thread.py +++ b/NG-RO/osm_ng_ro/tests/test_ns_thread.py @@ -817,6 +817,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": None, "vim_details": "some-details", + "vim_message": None, "refresh_at": None, }, "modified_at": 1637324200.994312, @@ -871,6 +872,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": "BUILD", "vim_details": "", + "vim_message": None, "refresh_at": None, }, "modified_at": 1637324200.994312, @@ -926,6 +928,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": "BUILD", "vim_details": "", + "vim_message": None, "refresh_at": None, }, "modified_at": 1637324200.994312, @@ -945,7 +948,7 @@ class TestVimInteractionNet(unittest.TestCase): task_status = "FAILED" ro_vim_item_update = { "vim_status": "ERROR", - "vim_details": "some error message", + "vim_message": "some error message", } result = instance.refresh(ro_task) self.assertEqual(result[0], task_status) @@ -981,6 +984,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": "BUILD", "vim_details": "", + "vim_message": None, "refresh_at": None, }, "modified_at": 1637324200.994312, @@ -1025,6 +1029,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": "BUILD", "vim_details": "", + "vim_message": None, "refresh_at": None, }, "modified_at": 163724200.994312, @@ -1043,7 +1048,7 @@ class TestVimInteractionNet(unittest.TestCase): task_status = "FAILED" ro_vim_item_update = { "vim_status": "DELETED", - "vim_details": "Deleted externally", + "vim_message": "Deleted externally", "vim_id": None, } result = instance.refresh(ro_task) @@ -1081,6 +1086,7 @@ class TestVimInteractionNet(unittest.TestCase): "vim_name": "test-vim", "vim_status": "BUILD", "vim_details": "", + "vim_message": None, "refresh_at": None, }, "modified_at": 163724211.994312, @@ -1240,6 +1246,7 @@ class TestVimInteractionAffinityGroup(unittest.TestCase): "vim_name": "sample_affinity_group_id_3", "vim_status": None, "vim_details": "some-details", + "vim_message": None, "refresh_at": None, }, } @@ -1250,7 +1257,7 @@ class TestVimInteractionAffinityGroup(unittest.TestCase): ) result = instance.delete(ro_task, task_index) self.assertEqual(result[0], "DONE") - self.assertEqual(result[1].get("vim_details"), "DELETED") + self.assertEqual(result[1].get("vim_message"), "DELETED") self.assertEqual(result[1].get("created"), False) self.assertEqual(result[1].get("vim_status"), "DELETED") @@ -1286,6 +1293,7 @@ class TestVimInteractionAffinityGroup(unittest.TestCase): "vim_name": None, "vim_status": None, "vim_details": "some-details", + "vim_message": None, "refresh_at": None, }, } @@ -1294,6 +1302,6 @@ class TestVimInteractionAffinityGroup(unittest.TestCase): self.target_vim.delete_affinity_group.return_value = "" result = instance.delete(ro_task, task_index) self.assertEqual(result[0], "DONE") - self.assertEqual(result[1].get("vim_details"), "DELETED") + self.assertEqual(result[1].get("vim_message"), "DELETED") self.assertEqual(result[1].get("created"), False) self.assertEqual(result[1].get("vim_status"), "DELETED") diff --git a/releasenotes/notes/Fix_bug_2022-5e7655a0e8227c36.yaml b/releasenotes/notes/Fix_bug_2022-5e7655a0e8227c36.yaml new file mode 100644 index 00000000..1a6c5828 --- /dev/null +++ b/releasenotes/notes/Fix_bug_2022-5e7655a0e8227c36.yaml @@ -0,0 +1,22 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fixing Bug 2022: This patch prevents to override the vim_details when VM + is in error state. By this way, vim_details could be used for healing operations. + The messages regarding with the failure is kept in another key names "vim_message". -- 2.25.1