Cloud-init is not starting after python upgrade

Hi Team,

We have upgraded the python version from python3.9.18 to python3.12.4 using the below steps.

login as root user

  1. yum update
  2. Go to /usr/src folder
  3. Download wget
    https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz
  4. Unarchive tar -xf Python-3.12.3.tgz
  5. Install Dependencies using the command : sudo yum install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel readline-devel sqlite-devel
  6. cd Python-3.12.3
  7. ./configure --enable-optimizations
  8. sudo make install
  9. sudo ln -sf /usr/local/bin/python3.12 /usr/bin/python
  10. sudo ln -sf /usr/local/bin/python3.12 /usr/bin/python3

Upon executing this steps. Cloud-init is failing with some module error. PFB Logs.
cloud-init[18187]: ^^^^^^^^^^^^^^^^^^^^^^^
cloud-init[18187]: File “/usr/lib64/python3.12/importlib/metadata/init.py”, line 861,>
cloud-init[18187]: return Distribution.from_name(distribution_name)
cloud-init[18187]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cloud-init[18187]: File “/usr/lib64/python3.12/importlib/metadata/init.py”, line 399,>
cloud-init[18187]: raise PackageNotFoundError(name)
cloud-init[18187]: importlib.metadata.PackageNotFoundError: No package metadata was found f>
systemd[1]: cloud-init.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: cloud-init.service: Failed with result ‘exit-code’.
systemd[1]: Failed to start Initial cloud-init job (metadata service crawler)

Thank you in Advance

Undo the upgrade. It has broken your system.

Once you have restored the platform python (if you still can), do look at the packages named python3.12*. They are in ‘appstream’ and can co-exist with the platform python.

I have pointed my python now to python3.9 and cloudinit is working.
How can I make the cloudinit to work on python 3.12?

Can you elaborate on this ?
do look at the packages named python3.12* . They are in ‘appstream’ and can co-exist with the platform python

Thanks in advance

See output of dnf list python3.12\*
Install the ones you want/need.

They will not replace the (3.9-based) platform python. There will be executable named python3.12, while the python3 and python3.9remain the platform python.

The cloud-init in Alma is built to work with the platform python. If you want your own version, then you have to build one with the python3.12. (I don’t actually know what it takes to build cloud-init.)