From 2612aa7e6585c8637df47915226141da436f42cf Mon Sep 17 00:00:00 2001 From: Bart Wensley Date: Thu, 14 Feb 2019 13:07:52 -0600 Subject: [PATCH] Fix compute host delete with no kubernetes node When a compute host is deleted, the VIM attempts to delete the node from kubernetes. However, if a compute host was powered on and the personality was set, but the host was never installed, no kubernetes node will exist for the host. When the VIM attempts to delete the node from kubernetes, the API returns a failure and the VIM doesn't handle that properly, so it continues to attempt to delete the node over and over. The fix is to handle the NOT_FOUND response from the delete API and treat that as a success. Change-Id: If9ca8baae4252a46ed7a514b2e91586436262688 Story: 2002843 Task: 29496 Signed-off-by: Bart Wensley --- .../nfvi_plugins/clients/kubernetes_client.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/clients/kubernetes_client.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/clients/kubernetes_client.py index 1f4bca6a..ab40f353 100644 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/clients/kubernetes_client.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/clients/kubernetes_client.py @@ -119,6 +119,18 @@ def delete_node(node_name): # Delete the node body = kubernetes.client.V1DeleteOptions() - response = kube_client.delete_node(node_name, body) + + try: + response = kube_client.delete_node(node_name, body) + except ApiException as e: + if e.status == httplib.NOT_FOUND: + # In some cases we may attempt to delete a node that exists in + # the VIM, but not yet in kubernetes (e.g. when the node is first + # being configured). Ignore the failure. + DLOG.info("Not deleting node %s because it doesn't exist" % + node_name) + return + else: + raise return Result(response)