ansible-collections / community.kubernetes

Kubernetes Collection for Ansible
https://galaxy.ansible.com/community/kubernetes
GNU General Public License v3.0
265 stars 104 forks source link

openshift `0.12.0` issues #384

Closed acelinkio closed 3 years ago

acelinkio commented 3 years ago
SUMMARY

ansible' community.kubernetes.k8s returns Failed to get client due to 404

The full traceback is:
  File "/tmp/ansible_community.kubernetes.k8s_payload_tjuxku3c/ansible_community.kubernetes.k8s_payload.zip/ansible_collections/community/kubernetes/plugins/module_utils/common.py", line 265, in get_api_client
    return DynamicClient(kubernetes.client.ApiClient(configuration))
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py", line 71, in __init__
    self.__discoverer = discoverer(self, cache_file)
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 259, in __init__
    Discoverer.__init__(self, client, cache_file)
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 31, in __init__
    self.__init_cache()
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 78, in __init_cache
    self._load_server_info()
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/discovery.py", line 158, in _load_server_info
    'kubernetes': self.client.request('get', '/version', serializer=just_json)
  File "/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py", line 44, in inner
    raise api_exception(e)
fatal: [testarlan.internal-useast1.onsolve.com]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_key": null,
            "api_version": "v1",
            "append_hash": false,
            "apply": true,
            "ca_cert": null,
            "client_cert": null,
            "client_key": null,
            "context": null,
            "force": false,
            "host": null,
            "kind": "Namespace",
            "kubeconfig": null,
            "merge_type": null,
            "name": "testing",
            "namespace": null,
            "password": null,
            "persist_config": null,
            "proxy": null,
            "resource_definition": null,
            "src": null,
            "state": "present",
            "template": null,
            "username": null,
            "validate": null,
            "validate_certs": false,
            "wait": false,
            "wait_condition": null,
            "wait_sleep": 5,
            "wait_timeout": 120
        }
    },
    "msg": "Failed to get client due to 404\nReason: Not Found\nHTTP response headers: HTTPHeaderDict({'Content-Type': 'text/plain; charset=utf-8', 'Vary': 'Accept-Encoding', 'X-Content-Type-Options': 'nosniff', 'Date': 'Mon, 08 Mar 2021 21:49:29 GMT', 'Content-Length': '19'})\nHTTP response body: b'404 page not found\\n'\nOriginal traceback: \n  File \"/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py\", line 42, in inner\n    resp = func(self, *args, **kwargs)\n\n  File \"/usr/local/lib/python3.8/dist-packages/openshift/dynamic/client.py\", line 235, in request\n    return self.client.call_api(\n\n  File \"/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py\", line 348, in call_api\n    return self.__call_api(resource_path, method,\n\n  File \"/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py\", line 180, in __call_api\n    response_data = self.request(\n\n  File \"/usr/local/lib/python3.8/dist-packages/kubernetes/client/api_client.py\", line 373, in request\n    return self.rest_client.GET(url,\n\n  File \"/usr/local/lib/python3.8/dist-packages/kubernetes/client/rest.py\", line 239, in GET\n    return self.request(\"GET\", url,\n\n  File \"/usr/local/lib/python3.8/dist-packages/kubernetes/client/rest.py\", line 233, in request\n    raise ApiException(http_resp=r)\n"
}
ISSUE TYPE
COMPONENT NAME

community.kubernetes.k8s

ANSIBLE VERSION
ansible 2.10.5
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.10 (default, Feb 16 2021, 20:05:09) [GCC 10.2.1 20201203]
CONFIGURATION
null
OS / ENVIRONMENT

Ubuntu 20.04

STEPS TO REPRODUCE
    - name: "install basic packages"
      ansible.builtin.apt:
        name:
          - jq
          - libpq-dev
          - python3-dev
          - python3-pip
          - docker.io
          - conntrack 
          - socat
        update_cache: yes
      become: yes

    - name: "Install required Ansible Python modules"
      pip: 
        name: 
          - openshift==0.12.0
          - PyYAML>=3.11
      become: yes

# kubernetes 1.20 was already installed via k3s

    - name: Create a k8s namespace
      community.kubernetes.k8s:
        name: testing
        api_version: v1
        kind: Namespace
        state: present
        apply: yes
        validate_certs: no
      become: yes
      environment:
        KUBECONFIG: /etc/rancher/k3s/k3s.yaml
EXPECTED RESULTS
PLAY [test k8s namespace] ******************************************************
TASK [Gathering Facts] *********************************************************
ok: [testarlan.internal-useast1.onsolve.com]
TASK [Create a k8s namespace] **************************************************
changed: [testarlan.internal-useast1.onsolve.com]
PLAY RECAP *********************************************************************
testarlan.internal-useast1.onsolve.com : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

expected results returned when reverting to openshift==0.11.0

tima commented 3 years ago

@AcelinkIT This sounds like a symptom of all of the python kubernetes-client 12.0 breaking change work that was in the 1.2.0 release. See #314 for all of the work that went into that. Install kubernetes.core 1.2.0 and try that with openshift 0.12 or keep with openshift 0.11 and the version of this collection you already have.

acelinkio commented 3 years ago

@tima thanks for the response. Did not see those issues during my search, probably would have saved hours of troubleshooting. Closing ticket as this type of issue appears to be known. Thanks!