Support host delete for kubernetes nodes
When a host is deleted, the VIM will now use the kubernetes API to delete the kubernetes node, if kubernetes is configured. Story: 2002843 Task: 27032 Change-Id: I7528baabe9fff96b092871b5615d2aa75165fbee Signed-off-by: Bart Wensley <barton.wensley@windriver.com>
This commit is contained in:
parent
7113af25ef
commit
5be8168832
@ -108,3 +108,17 @@ def untaint_node(node_name, effect, key):
|
|||||||
response = kube_client.patch_node(node_name, body)
|
response = kube_client.patch_node(node_name, body)
|
||||||
|
|
||||||
return Result(response)
|
return Result(response)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_node(node_name):
|
||||||
|
"""
|
||||||
|
Delete a node
|
||||||
|
"""
|
||||||
|
# Get the client.
|
||||||
|
kube_client = get_client()
|
||||||
|
|
||||||
|
# Delete the node
|
||||||
|
body = kubernetes.client.V1DeleteOptions()
|
||||||
|
response = kube_client.delete_node(node_name, body)
|
||||||
|
|
||||||
|
return Result(response)
|
||||||
|
@ -1078,6 +1078,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
if httplib.NOT_FOUND != e.http_status_code:
|
if httplib.NOT_FOUND != e.http_status_code:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
if self._host_supports_kubernetes(host_personality):
|
||||||
|
response['reason'] = 'failed to delete kubernetes services'
|
||||||
|
|
||||||
|
# Send the delete request to kubernetes.
|
||||||
|
future.work(kubernetes_client.delete_node, host_name)
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("Kubernetes delete_node failed, operation "
|
||||||
|
"did not complete, host_uuid=%s, host_name=%s."
|
||||||
|
% (host_uuid, host_name))
|
||||||
|
return
|
||||||
|
|
||||||
response['completed'] = True
|
response['completed'] = True
|
||||||
response['reason'] = ''
|
response['reason'] = ''
|
||||||
|
|
||||||
@ -1148,6 +1161,21 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
self._platform_token = future.result.data
|
self._platform_token = future.result.data
|
||||||
|
|
||||||
|
if self._host_supports_kubernetes(host_personality):
|
||||||
|
response['reason'] = 'failed to enable kubernetes services'
|
||||||
|
|
||||||
|
# To enable kubernetes we remove the NoExecute taint from the
|
||||||
|
# node. This allows new pods to be scheduled on the node.
|
||||||
|
future.work(kubernetes_client.untaint_node,
|
||||||
|
host_name, "NoExecute", "services")
|
||||||
|
future.result = (yield)
|
||||||
|
|
||||||
|
if not future.result.is_complete():
|
||||||
|
DLOG.error("Kubernetes untaint_node failed, operation "
|
||||||
|
"did not complete, host_uuid=%s, host_name=%s."
|
||||||
|
% (host_uuid, host_name))
|
||||||
|
return
|
||||||
|
|
||||||
if self._host_supports_neutron(host_personality):
|
if self._host_supports_neutron(host_personality):
|
||||||
response['reason'] = 'failed to get neutron extensions'
|
response['reason'] = 'failed to get neutron extensions'
|
||||||
|
|
||||||
@ -1223,21 +1251,6 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
"did not complete, host_uuid=%s, host_name=%s."
|
"did not complete, host_uuid=%s, host_name=%s."
|
||||||
% (host_uuid, host_name))
|
% (host_uuid, host_name))
|
||||||
|
|
||||||
if self._host_supports_kubernetes(host_personality):
|
|
||||||
response['reason'] = 'failed to enable kubernetes services'
|
|
||||||
|
|
||||||
# To enable kubernetes we remove the NoExecute taint from the
|
|
||||||
# node. This allows new pods to be scheduled on the node.
|
|
||||||
future.work(kubernetes_client.untaint_node,
|
|
||||||
host_name, "NoExecute", "services")
|
|
||||||
future.result = (yield)
|
|
||||||
|
|
||||||
if not future.result.is_complete():
|
|
||||||
DLOG.error("Kubernetes untaint_node failed, operation "
|
|
||||||
"did not complete, host_uuid=%s, host_name=%s."
|
|
||||||
% (host_uuid, host_name))
|
|
||||||
return
|
|
||||||
|
|
||||||
response['completed'] = True
|
response['completed'] = True
|
||||||
response['reason'] = ''
|
response['reason'] = ''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user