Skip to content

Compatability with kubernetes >= 32.0.0 #868

Open
@sebhoss

Description

@sebhoss
SUMMARY

After upgrading the Python kubernetes library to version 32+, we can no longer use the kubernetes.core Ansible module.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

k8s_info but it think it affects all components

ANSIBLE VERSION
uv run -- ansible --version
ansible [core 2.18.1]
  config file = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/ansible.cfg
  configured module search path = ['/home/seb/.config/ansible/home/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.ansible
  executable location = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.venv/bin/ansible
  python version = 3.13.0 (main, Oct  8 2024, 01:04:00) [Clang 18.1.8 ] (/var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.venv/bin/python3)
  jinja version = 3.1.5
  libyaml = True
COLLECTION VERSION
uv run -- ansible-galaxy collection list kubernetes.core

# /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.ansible/ansible_collections
Collection      Version
--------------- -------
kubernetes.core 5.1.0  

# /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.venv/lib/python3.13/site-packages/ansible_collections
Collection      Version
--------------- -------
kubernetes.core 5.1.0  
CONFIGURATION
ANSIBLE_HOME(env: ANSIBLE_HOME) = /home/seb/.config/ansible/home
COLLECTIONS_PATHS(/var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/ansible.cfg) = ['/var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.ansible']
CONFIG_FILE() = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/ansible.cfg
DEFAULT_VAULT_PASSWORD_FILE(/var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/ansible.cfg) = /var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/.VAULT_PASSWORD
EDITOR(env: EDITOR) = /var/home/seb/.local/bin/hx
GALAXY_CACHE_DIR(env: ANSIBLE_GALAXY_CACHE_DIR) = /home/seb/.cache/ansible/galaxy
INTERPRETER_PYTHON(/var/home/seb/git/git.infra.run/infra.run/infrastructure/helm-deployments/main/ansible.cfg) = auto_silent
MAX_FILE_SIZE_FOR_DIFF(env: ANSIBLE_MAX_DIFF_SIZE) = 104857600
PAGER(env: PAGER) = less

GALAXY_SERVERS:
OS / ENVIRONMENT

Fedora 41

STEPS TO REPRODUCE
- name: Check whether namespace exists
  delegate_to: localhost
  kubernetes.core.k8s_info:
    api_version: v1
    kind: Namespace
    name: "{{ k8s_namespace_name }}"
    context: "{{ kubectl_context }}"
  register: k8s_namespace
EXPECTED RESULTS

We want to see successful results from k8s modules

ACTUAL RESULTS

We are seeing strack traces like this:

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/dynamic/client.py", line 273, in request
            api_response = self.client.call_api(
                path,
            ...<11 lines>...
                _request_timeout=params.get('_request_timeout')
            )

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/client/api_client.py", line 348, in call_api
            return self.__call_api(resource_path, method,
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
                                   path_params, query_params, header_params,
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            ...<2 lines>...
                                   _return_http_data_only, collection_formats,
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   _preload_content, _request_timeout, _host)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/client/api_client.py", line 180, in __call_api
            response_data = self.request(
                method, url, query_params=query_params, headers=header_params,
                post_params=post_params, body=body,
                _preload_content=_preload_content,
                _request_timeout=_request_timeout)

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/client/api_client.py", line 373, in request
            return self.rest_client.GET(url,
                   ~~~~~~~~~~~~~~~~~~~~^^^^^
                                        query_params=query_params,
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
                                        _preload_content=_preload_content,
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                        _request_timeout=_request_timeout,
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                        headers=headers)
                                        ^^^^^^^^^^^^^^^^

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/client/rest.py", line 244, in GET
            return self.request("GET", url,
                   ~~~~~~~~~~~~^^^^^^^^^^^^
                                headers=headers,
                                ^^^^^^^^^^^^^^^^
                                _preload_content=_preload_content,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                _request_timeout=_request_timeout,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                query_params=query_params)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^

          File "/home/haggl/repositories/infra.run/infrastructure/helm-deployments/.venv/lib/python3.13/site-packages/kubernetes/client/rest.py", line 238, in request
            raise ApiException(http_resp=r)
    module_stdout: ''
    msg: |-
        MODULE FAILURE: No start of json char found
        See stdout/stderr for the exact error

Downgrading kubernetes to the latest 31.X version fixes this for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs_infoNeeds additional information from original reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions