Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetes/preinstall fails due to missing jsonschema package #11153

Closed
Ladicle opened this issue May 2, 2024 · 2 comments · Fixed by #11154
Closed

kubernetes/preinstall fails due to missing jsonschema package #11153

Ladicle opened this issue May 2, 2024 · 2 comments · Fixed by #11154
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Ladicle
Copy link
Contributor

Ladicle commented May 2, 2024

What happened?

The task Verify that the packages list structure is valid failed because the jsonschema package was missing. That task uses the ansible.utils.validate module, and its default engine is ansible.utils.jsonschema.
https://docs.ansible.com/ansible/latest/collections/ansible/utils/validate_module.html

My Python environment is managed by venv, which I set up following the psetting-up-your-first-cluster guide.

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

What did you expect to happen?

Expect all required Python packages to be defined in requirements.txt.

How can we reproduce it (as minimally and precisely as possible)?

python3 -m venv venv
source venv/bin/activate
pip install -U -r requirements.txt

OS

Darwin 23.4.0 arm64

Version of Ansible

ansible [core 2.16.6]
  config file = /Users/ladicle/src/github.com/Ladicle/kubespray/ansible.cfg
  configured module search path = ['/Users/ladicle/src/github.com/Ladicle/kubespray/library']
  ansible python module location = /Users/ladicle/src/github.com/Ladicle/kubespray/venv/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/ladicle/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/ladicle/src/github.com/Ladicle/kubespray/venv/bin/ansible
  python version = 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] (/Users/ladicle/src/github.com/Ladicle/kubespray/venv/bin/python3.12)
  jinja version = 3.1.3
  libyaml = True

Version of Python

Python 3.12.3

Version of Kubespray (commit)

f9e76689a

Network plugin used

cilium

Full inventory with variables

Use the below inventry.ini, and use the sample variables (no customize).

node1 ansible_host=178.1.10.183

[kube_control_plane]
node1

[etcd]
node1

[kube_node]
node1

[k8s_cluster:children]
kube_node
kube_control_plane

Command used to invoke ansible

ansible-playbook -i inventory/mycluster/inventry.ini cluster.yml -b -v -u ubuntu --private-key=~/.ssh/private_key

Output of ansible run

TASK [kubernetes/preinstall : Verify that the packages list structure is valid] **********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleError: Failed to import the required Python library (jsonschema) on air-8.local's Python /Users/ladicle/src/github.com/kubernetes-sigs/kubespray/venv/bin/python3.12. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter
fatal: [node1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (jsonschema) on air-8.local's Python /Users/ladicle/src/github.com/kubernetes-sigs/kubespray/venv/bin/python3.12. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}

NO MORE HOSTS LEFT ***********************************************************************

PLAY RECAP *******************************************************************************
node1                      : ok=69   changed=1    unreachable=0    failed=1    skipped=38   rescued=0    ignored=0

Thursday 02 May 2024  12:01:15 +0900 (0:00:00.023)       0:00:14.366 **********
===============================================================================
bootstrap-os : Gather facts ------------------------------------------------------- 1.40s
bootstrap-os : Assign inventory name to unconfigured hostnames (non-CoreOS, non-Flatcar, Suse and ClearLinux, non-Fedora) --- 1.20s
Gather necessary facts (hardware) ------------------------------------------------- 1.16s
bootstrap-os : Create remote_tmp for it is used by another module ----------------- 0.86s
kubernetes/preinstall : Mask swap.target (persist swapoff) ------------------------ 0.74s
kubernetes/preinstall : Remove swapfile from /etc/fstab --------------------------- 0.60s
Gather minimal facts -------------------------------------------------------------- 0.59s
Gather necessary facts (network) -------------------------------------------------- 0.57s
bootstrap-os : Ensure bash_completion.d folder exists ----------------------------- 0.52s
adduser : User | Create User ------------------------------------------------------ 0.48s
adduser : User | Create User Group ------------------------------------------------ 0.41s
kubernetes/preinstall : Check /usr readonly --------------------------------------- 0.40s
kubernetes/preinstall : Get content of /etc/resolv.conf --------------------------- 0.40s
kubernetes/preinstall : Check if /etc/fstab exists -------------------------------- 0.38s
kubernetes/preinstall : Disable swap ---------------------------------------------- 0.36s
kubernetes/preinstall : Check resolvconf ------------------------------------------ 0.34s
kubernetes/preinstall : Check systemd-resolved ------------------------------------ 0.34s
kubernetes/preinstall : Check if kubelet is configured ---------------------------- 0.33s
kubernetes/preinstall : Check if /etc/dhcp/dhclient.conf exists ------------------- 0.32s
kubernetes/preinstall : NetworkManager | Check if host has NetworkManager --------- 0.30s

Anything else we need to know

No response

@Ladicle Ladicle added the kind/bug Categorizes issue or PR as related to a bug. label May 2, 2024
@deleteprod
Copy link

I get this:

(base) ➜ kubespray git:(master) brew install jsonschema Error: jsonschema has been disabled because it cli is deprecated, and will be removed!

Then this:

(base) ➜ kubespray git:(master) pip3 install jsonschema Requirement already satisfied: jsonschema in /Users/martyn/anaconda3/lib/python3.11/site-packages (4.17.3) Requirement already satisfied: attrs>=17.4.0 in /Users/martyn/anaconda3/lib/python3.11/site-packages (from jsonschema) (22.1.0) Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /Users/martyn/anaconda3/lib/python3.11/site-packages (from jsonschema) (0.18.0)

Then when both Homebrew and Python are happy - this:

fatal: [node1]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (jsonschema) on chiefwiggum's Python /opt/homebrew/Cellar/ansible/9.4.0/libexec/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"} An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleError: Failed to import the required Python library (jsonschema) on chiefwiggum's Python /opt/homebrew/Cellar/ansible/9.4.0/libexec/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter

@deleteprod
Copy link

`(base) ➜ kubespray git:(master) python --version
Python 3.11.5
(base) ➜ kubespray git:(master) python
Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import jsonschema
print("No errors on interactive import")
No errors on interactive import

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants