postgresql_cluster icon indicating copy to clipboard operation
postgresql_cluster copied to clipboard

Add support for Ubuntu 24.04

Open vitabaks opened this issue 1 year ago • 3 comments

Add support for Ubuntu 24.04

Postponed. There is a problem with the compatibility of the pip requirements with Python 3.12

fatal: [10.172.0.20]: FAILED! => {"changed": false, "cmd": ["/usr/bin/pip3", "install", "--trusted-host=pypi.python.org", "--trusted-host=pypi.org", "--trusted-host=files.pythonhosted.org", "-r", "/tmp/requirements.txt"], "msg": "stdout: Collecting urllib3>=1.25.9 (from -r /tmp/requirements.txt (line 1))\n  Downloading urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)\nCollecting boto3 (from -r /tmp/requirements.txt (line 2))\n  Downloading boto3-1.34.92-py3-none-any.whl.metadata (6.6 kB)\nRequirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 3)) (6.0.1)\nCollecting requests>=2.25.1 (from -r /tmp/requirements.txt (line 4))\n  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)\nRequirement already satisfied: six>=1.7 in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 5)) (1.16.0)\nCollecting python-etcd<0.5,>=0.4.3 (from -r /tmp/requirements.txt (line 6))\n  Downloading python-etcd-0.4.5.tar.gz (37 kB)\n  Preparing metadata (setup.py): started\n  Preparing metadata (setup.py): finished with status 'error'\n\n:stderr:   error: subprocess-exited-with-error\n  \n  × python setup.py egg_info did not run successfully.\n  │ exit code: 1\n  ╰─> [11 lines of output]\n      Traceback (most recent call last):\n        File \"<string>\", line 2, in <module>\n        File \"<pip-setuptools-caller>\", line 14, in <module>\n        File \"/usr/local/lib/python3.12/dist-packages/setuptools/__init__.py\", line 16, in <module>\n          import setuptools.version\n        File \"/usr/local/lib/python3.12/dist-packages/setuptools/version.py\", line 1, in <module>\n          import pkg_resources\n        File \"/usr/local/lib/python3.12/dist-packages/pkg_resources/__init__.py\", line 2191, in <module>\n          register_finder(pkgutil.ImpImporter, find_on_path)\n                          ^^^^^^^^^^^^^^^^^^^\n      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: metadata-generation-failed\n\n× Encountered error while generating package metadata.\n╰─> See above for output.\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n"}

vitabaks avatar Apr 26 '24 10:04 vitabaks

The python-etcd-0.4.5 and ydiff-1.3 packages are not compatible with Python 3.12

root@pgnode01:/# pip3 install -r /tmp/requirements.txt 
Collecting urllib3>=1.25.9 (from -r /tmp/requirements.txt (line 1))
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting boto3 (from -r /tmp/requirements.txt (line 2))
  Using cached boto3-1.34.92-py3-none-any.whl.metadata (6.6 kB)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 3)) (6.0.1)
Collecting requests>=2.25.1 (from -r /tmp/requirements.txt (line 4))
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Requirement already satisfied: six>=1.7 in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 5)) (1.16.0)
Collecting python-etcd<0.5,>=0.4.3 (from -r /tmp/requirements.txt (line 6))
  Using cached python-etcd-0.4.5.tar.gz (37 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "/usr/local/lib/python3.12/dist-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/usr/local/lib/python3.12/dist-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/usr/local/lib/python3.12/dist-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Collecting urllib3>=1.25.9 (from -r /tmp/requirements.txt (line 1))
  Using cached urllib3-2.2.1-py3-none-any.whl.metadata (6.4 kB)
Collecting boto3 (from -r /tmp/requirements.txt (line 2))
  Using cached boto3-1.34.92-py3-none-any.whl.metadata (6.6 kB)
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 3)) (6.0.1)
Collecting requests>=2.25.1 (from -r /tmp/requirements.txt (line 4))
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Requirement already satisfied: six>=1.7 in /usr/lib/python3/dist-packages (from -r /tmp/requirements.txt (line 5)) (1.16.0)
Collecting python-consul>=0.7.1 (from -r /tmp/requirements.txt (line 6))
  Downloading python_consul-1.1.0-py2.py3-none-any.whl.metadata (11 kB)
Collecting click>=4.1 (from -r /tmp/requirements.txt (line 7))
  Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting prettytable>=0.7 (from -r /tmp/requirements.txt (line 8))
  Downloading prettytable-3.10.0-py3-none-any.whl.metadata (30 kB)
Collecting python-dateutil (from -r /tmp/requirements.txt (line 9))
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting psutil>=2.0.0 (from -r /tmp/requirements.txt (line 10))
  Downloading psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)
Collecting ydiff>=1.2.0 (from -r /tmp/requirements.txt (line 11))
  Downloading ydiff-1.3.tar.gz (74 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 74.1/74.1 kB 1.8 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "/usr/local/lib/python3.12/dist-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/usr/local/lib/python3.12/dist-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/usr/local/lib/python3.12/dist-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

vitabaks avatar Apr 26 '24 10:04 vitabaks

Could this be helpful? It looks like in 24.04 you are forced to create a virtual environment. By the way, the bug you referenced here was caused by a related problem: version conflicts between Python packages installed by apt and pip. It appears to be fixed.

skauk avatar May 02 '24 14:05 skauk

Perhaps we will switch from pip to rpm/deb (patroni_installation_method) by default for patroni packages.

vitabaks avatar May 02 '24 21:05 vitabaks

I was able to successfully set up the cluster on Ubuntu 24.04 by:

  • checking out the Git branch for this PR, and rebasing it off master
  • connecting to each node, and:
    • installing the following packages via APT:
      • python3-packaging
      • python3-pycparser
      • python3-consul
    • running python3 -m pip install --upgrade setuptools --break-system-packages as root
    • installing patroni[dependencies] via pip, using the --break-system-packages option, which should now succeed
  • commenting out the part where patroni dependencies are installed in the Ansible playbook
  • running the playbook with the parts commented out
  • setting the file permissions for /etc/postgresql/16/main/postgresql.conf to 644 on each node
  • rebooting all nodes

not sure how much of this is necessary, but I hope it at least helps! FWIW, I set up the basic failover cluster.

JohnTheNerd avatar Jul 07 '24 04:07 JohnTheNerd

I was able to successfully set up the cluster on Ubuntu 24.04 by

In your case, the key is that you are using consul and you did not need to install the outdated python-etcd package.

vitabaks avatar Aug 02 '24 09:08 vitabaks

To ensure compatibility with Ubuntu 22.04 (and Python 3.12), the Patroni package will be installed from the deb/rpm package by default.

vitabaks avatar Aug 02 '24 12:08 vitabaks