openshift/openshift-restclient-python

Getting unicodedecode errors while using Openshift_raw module on ansible.

iamaquaman opened this issue · 1 comments

 "changed": false,
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1566514104.1-150593016179423/AnsiballZ__openshift_raw.py\", line 113, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1566514104.1-150593016179423/AnsiballZ__openshift_raw.py\", line 105, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1566514104.1-150593016179423/AnsiballZ__openshift_raw.py\", line 48, in invoke_module\r\n    imp.load_module('__main__', mod, module, MOD_DESC)\r\n  File \"/tmp/ansible_openshift_raw_payload_GA_O0b/__main__.py\", line 171, in <module>\r\n  File \"/tmp/ansible_openshift_raw_payload_GA_O0b/__main__.py\", line 167, in main\r\n  File \"/tmp/ansible_openshift_raw_payload_GA_O0b/ansible_openshift_raw_payload.zip/ansible/module_utils/k8s/raw.py\", line 89, in execute_module\r\n  File \"/tmp/ansible_openshift_raw_payload_GA_O0b/ansible_openshift_raw_payload.zip/ansible/module_utils/k8s/common.py\", line 162, in get_api_client\r\n  File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 562, in load_kube_config\r\n    loader.load_and_set(config)\r\n  File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 444, in load_and_set\r\n    self._load_cluster_info()\r\n  File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 407, in _load_cluster_info\r\n    file_base_path=self._config_base_path).as_file()\r\n  File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 114, in as_file\r\n    base64.standard_b64decode(content))\r\n  File \"/usr/lib/python2.7/site-packages/kubernetes/config/kube_config.py\", line 71, in _create_temp_file_with_content\r\n    fd.write(content.encode() if isinstance(content, str) else content)\r\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 150733: ordinal not in range(128)\r\n",
    "rc": 1,
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
}

I am using the latest verions of the opeshift-restclient and the kubernetes python client.

We have fixed this issue on our end.

It turned out the root cause was that the kubeconfig file on that node was too big, with ssl cert and key data directly embedded in it, within huge strings. The openshift_raw module is merely calling the kubernetes python client, which was the real source of the error.

We removed the large certificate-authority-data strings, and replaced them with an external cert using certificate-authority: /path/to/cert/