Remove dependency of PyChef in deploy-tooling
Problem statement
PyChef hasn't had a release since 2016 https://pypi.org/project/PyChef/. Python version 3.8 is not compatible with this module unfortunately due to AttributeError: module 'platform' has no attribute 'linux_distribution'
. I think we will need to consider forking or removing our dependency on it.
Here is the error you will likely see:
$ bin/set-omnibus-updates $CURRENT_DEPLOY_ENVIRONMENT_STAGE --disable
Traceback (most recent call last):
File "/builds/gitlab-com/gl-infra/deployer/deploy-tooling/bin/set-omnibus-updates", line 6, in <module>
from chef import Role, ChefAPI
File "/usr/local/lib/python3.11/site-packages/chef/__init__.py", line 5, in <module>
from chef.api import ChefAPI, autoconfigure
File "/usr/local/lib/python3.11/site-packages/chef/api.py", line 17, in <module>
from chef.rsa import Key
File "/usr/local/lib/python3.11/site-packages/chef/rsa.py", line 12, in <module>
plat_name = platform.linux_distribution(supported_dists=['system'])[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'platform' has no attribute 'linux_distribution'
See also this stackoverflow post
To advance our Python version we are going to need to either stop using this module, fork it, or switch to something else (like Ruby). Introducing Ruby into the image is not great because it will increase the size of it.
We cannot proceed with our Ansible upgrade in #2127 (closed) until this is resolved
We depend on this python package for only setting the omnibus version, I think all we need to do here is come up with a different way to handle that.
Proposal for resolving
Copied from #2127 (comment 1519988090)
There are two scripts that depend on pychef, bin/set-omnibus-updates
and bin/set-version
-
bin/set-omnibus-updates
- This disables or enables Omnibus updates by updating the Chef role. -
/bin/set-version
- Updates the version in the omnibus role
To remove pychef, we will need to move this functionality out of Python scripts and instead use knife
directly or create a replacement ruby script. I would try the former first, using the official chef docker image.
We might end up creating a new job in the pipeline, but I don't think that will be a huge cost especially if this is needed to get us off of EOL versions.
Exit Criteria
-
New scripts are in use in place of the old ones -
Old scripts (that use PyChef) are removed and not used anywhere -
The test Chef role pychef-test-omnibus-version
is removed