Merge "Support host delete for kubernetes nodes"
This commit is contained in:
commit
fce17d8115
@ -108,3 +108,17 @@ def untaint_node(node_name, effect, key):
|
||||
response = kube_client.patch_node(node_name, body)
|
||||
|
||||
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:
|
||||
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['reason'] = ''
|
||||
|
||||
@ -1148,6 +1161,21 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
||||
|
||||
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):
|
||||
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."
|
||||
% (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['reason'] = ''
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user