Skip to content

Commit

Permalink
[CE-441][CE-447] Fix SSL and remove redundant code
Browse files Browse the repository at this point in the history
Currently, error will be thrown while user try to creat
kubernets type host with SSL enable and the get_config
function will try to list all pods in kubernetes cluster,
which is unnecessary since check_health function will do that,
this patch is meant to fix the SSL bug and delete redundant code.

CE-441 # done
CE-447 # done

Change-Id: I1ec1dccc59dace10f5c12cc64f6cec198eeff5ed
Signed-off-by: luke <jiahaochen1993@gmail.com>
  • Loading branch information
jiahaoc1993 committed Aug 30, 2018
1 parent a4017f5 commit 3e22eab
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/agent/k8s/host_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,12 @@ def _get_config_from_params(self, k8s_params):
k8s_config.verify_ssl = False
else:
k8s_config.verify_ssl = True
k8s_config.ssl_ca_cert = k8s_params.get('K8SSslCert')
k8s_config.ssl_ca_cert = \
config.kube_config. \
_create_temp_file_with_content(k8s_params.get('K8SSslCert'))

client.Configuration.set_default(k8s_config)

v1 = client.CoreV1Api()
try:
v1.list_pod_for_all_namespaces(watch=False)
except Exception as e:
error_msg = (
"Cannot create kubernetes host due "
"to an incorrect parameters."
)
logger.error("Kubernetes host error msg: {}".format(e))
raise Exception(error_msg)

return k8s_config

def check_host(self, k8s_params):
Expand Down

0 comments on commit 3e22eab

Please sign in to comment.