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

CFE-1124: Install ansible using pip instead of rpm #20

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

arkadeepsen
Copy link
Member

@arkadeepsen arkadeepsen commented Aug 28, 2024

Description of the change:
This PR updates the Dockerfile to use pip instead of rpm to install ansible dependencies.

Following changes are made in this PR:

  • Add Dockerfile.requirements for generating the requirements.txt and requirments-build.txt files from the upstream Pipfile
  • Add make target to generate the requirements. Add make target to check if the current requirements.txt and requirements-build.txt files are up-to-date
  • Update Dockerfile to use cachito speicific env vars for installing the python modules using pip
  • Remove unused shell scripts and inline the user creation script in the Dockerfile
  • Update base images to rhel9 in Dockerfile

Motivation for the change:

In rhel8, ansible-core rpm uses python3.12, while the other ansible dependencies (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) use python3.6. This is causing ansible-runner to not find ansible during runtime of the operator created using the ansible-operator base image.

In rhel9, the various dependencies of ansible (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) will not be available as part of rpm packages.

For the above reasons ansible is being installed using pip instead of rpm.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 28, 2024
Copy link

openshift-ci bot commented Aug 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arkadeepsen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 28, 2024
@arkadeepsen arkadeepsen force-pushed the ansible-core branch 3 times, most recently from 2ba27f3 to f429941 Compare August 29, 2024 11:14
@arkadeepsen arkadeepsen force-pushed the ansible-core branch 2 times, most recently from 56b540d to 055157e Compare September 5, 2024 12:08
@arkadeepsen
Copy link
Member Author

/test all

@arkadeepsen
Copy link
Member Author

/retest

1 similar comment
@arkadeepsen
Copy link
Member Author

/retest

@arkadeepsen arkadeepsen force-pushed the ansible-core branch 2 times, most recently from 39f84f0 to a9dfd45 Compare September 9, 2024 04:52
@arkadeepsen arkadeepsen changed the title [WIP] DNM: Install ansible-core instead of ansible CFE-1124: Install ansible-core instead of ansible Sep 9, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 9, 2024

@arkadeepsen: This pull request references CFE-1124 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.18.0" version, but no target version was set.

In response to this:

Description of the change:

Motivation for the change:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 9, 2024
@arkadeepsen arkadeepsen force-pushed the ansible-core branch 6 times, most recently from 66c3432 to cb12ea5 Compare September 9, 2024 13:08
@arkadeepsen arkadeepsen changed the title CFE-1124: Install ansible-core instead of ansible CFE-1124: Install ansible using pip instead of rpm Sep 9, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 9, 2024

@arkadeepsen: This pull request references CFE-1124 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.18.0" version, but no target version was set.

In response to this:

Description of the change:
This PR updates the Dockerfile to use pip instead of rpm to install ansible dependencies.

Following changes are made in this PR:

  • Add Dockerfile.requirements for generating the requirements.txt and requirments-build.txt files from the upstream Pipfile
  • Add make target to generate the requirements. Add make target to check if the current requirements.txt and requirements-build.txt files are up-to-date
  • Update Dockerfile to use cachito speicific env vars for installing the python modules using pip
  • Remove unused shell scripts and inline the user creation script in the Dockerfile
  • Update base images to rhel9 in Dockerfile

Motivation for the change:

In rhel8, ansible-core rpm uses python3.12, while the other ansible dependencies (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) use python3.6. This is causing ansible-runner to not find ansible during runtime of the operator created using the ansible-operator base image.

In rhel9, the various dependencies of ansible (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) will not be available as part of rpm packages.

For the above reasons ansible is being installed using pip instead of rpm.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@arkadeepsen arkadeepsen force-pushed the ansible-core branch 3 times, most recently from 01e052b to 4f8cfa9 Compare September 10, 2024 08:33
RUN python3 -m pip install pipenv==2023.11.15 \
&& python3 -m pip install pip-tools \
&& pipenv install --deploy \
&& pipenv run pip freeze --all > ./requirements.in \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to have check for cve using pipenv check or safety to fail-fast before the building the requirements.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we proceed if there are CVEs reported by pipenv check? The Pipfile and the Pipfile.lock are what we have from upstream. Do we go upstream first and update the files and then pull it downstream?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the timeline commitments. If the downstream release can wait till there is a release from upstream, then upstream fixes can rebased. Otherwise, the upstream carry commits can be created. Once the fix is available from upstream, the carry PRs can be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found the following vulnerabilities after using pipenv check --ignore 70612 --ignore 71064:

20.87 Checking Pipfile.lock packages for vulnerabilities...
20.87 Notice: Ignoring Vulnerabilities 70612, 71064
22.84 +==============================================================================+
22.84 
22.84                                /$$$$$$            /$$
22.84                               /$$__  $$          | $$
22.84            /$$$$$$$  /$$$$$$ | $$  \__//$$$$$$  /$$$$$$   /$$   /$$
22.84           /$$_____/ |____  $$| $$$$   /$$__  $$|_  $$_/  | $$  | $$
22.84          |  $$$$$$   /$$$$$$$| $$_/  | $$$$$$$$  | $$    | $$  | $$
22.84           \____  $$ /$$__  $$| $$    | $$_____/  | $$ /$$| $$  | $$
22.84           /$$$$$$$/|  $$$$$$$| $$    |  $$$$$$$  |  $$$$/|  $$$$$$$
22.84          |_______/  \_______/|__/     \_______/   \___/   \____  $$
22.84                                                           /$$  | $$
22.84                                                          |  $$$$$$/
22.84   by pyup.io                                              \______/
22.84 
22.84 +==============================================================================+
22.84 
22.84  REPORT 
22.84 
22.84   Safety v2.3.2 is scanning for Vulnerabilities...
22.84   Scanning dependencies in your files:
22.84 
22.84   -> /tmp/-x-v5uFv0wqfu2bdb_requirements.txt
22.84 
22.84   Found and scanned 37 packages
22.84   Timestamp 2024-09-19 16:09:39
22.84   5 vulnerabilities found
22.84   2 vulnerabilities ignored
22.84 
22.84 +==============================================================================+
22.84  VULNERABILITIES FOUND 
22.84 +==============================================================================+
22.84 
22.84 -> Vulnerability found in certifi version 2024.2.2
22.84    Vulnerability ID: 72083
22.84    Affected spec: >=2021.05.30,<2024.07.04
22.84    ADVISORY: Certifi affected versions recognized root certificates from
22.84    GLOBALTRUST. Certifi patch removes these root certificates from the root...
22.84    CVE-2024-39689
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/72083/742
22.84 
22.84 
22.84 -> Vulnerability found in cryptography version 42.0.7
22.84    Vulnerability ID: 71681
22.84    Affected spec: <42.0.8
22.84    ADVISORY: The `cryptography` library has updated its BoringSSL and
22.84    OpenSSL dependencies in CI due to a security concern. Specifically, the...
22.84    CVE-2024-4603
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/71681/742
22.84 
22.84 
22.84 -> Vulnerability found in jinja2 version 3.1.4
22.84    Vulnerability ID: 70612
22.84    This vulnerability is being ignored.
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/70612/742
22.84 
22.84 
22.84 -> Vulnerability found in requests version 2.31.0
22.84    Vulnerability ID: 71064
22.84    This vulnerability is being ignored.
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/71064/742
22.84 
22.84 
22.84 -> Vulnerability found in setuptools version 69.5.1
22.84    Vulnerability ID: 72236
22.84    Affected spec: <70.0.0
22.84    ADVISORY: Affected versions of Setuptools allow for remote code
22.84    execution via its download functions. These functions, which are used to...
22.84    CVE-2024-6345
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/72236/742
22.84 
22.84 
22.84 -> Vulnerability found in urllib3 version 1.26.18
22.84    Vulnerability ID: 71608
22.84    Affected spec: <=1.26.18
22.84    ADVISORY: Urllib3's ProxyManager ensures that the Proxy-Authorization
22.84    header is correctly directed only to configured proxies. However, when...
22.84    CVE-2024-37891
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/71608/742
22.84 
22.84 
22.84 -> Vulnerability found in zipp version 3.18.1
22.84    Vulnerability ID: 72132
22.84    Affected spec: <3.19.1
22.84    ADVISORY: A Denial of Service (DoS) vulnerability exists in the
22.84    jaraco/zipp library. The vulnerability is triggered when processing a...
22.84    CVE-2024-5569
22.84    For more information, please visit
22.84    https://data.safetycli.com/v/72132/742
22.84 
22.84  Scan was completed. 5 vulnerabilities were found. 2 vulnerabilities from 2 
22.84  packages were ignored. 
22.84 
22.84 +==============================================================================+
22.84    REMEDIATIONS
22.84 
22.84   5 vulnerabilities were found in 5 packages. For detailed remediation & fix 
22.84   recommendations, upgrade to a commercial license. 
22.84 
22.84 +==============================================================================+

How should we proceed now?

Copy link
Member Author

@arkadeepsen arkadeepsen Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addition to this we have to install cryptography using rpm as it cannot be built using cachito. Following are the versions available for cryptography:

bash-5.1$ yum --showduplicates list python3-cryptography
Last metadata expiration check: 0:03:40 ago on Thu Sep 19 17:10:30 2024.
Installed Packages
python3-cryptography.x86_64                                                                        36.0.1-2.el9                                                                        @ubi-9-appstream-rpms
Available Packages
python3-cryptography.x86_64                                                                        36.0.1-2.el9                                                                        ubi-9-appstream-rpms 
bash-5.1$ yum --showduplicates list python3.11-cryptography
Last metadata expiration check: 0:03:58 ago on Thu Sep 19 17:10:30 2024.
Available Packages
python3.11-cryptography.x86_64                                                                       37.0.2-6.el9                                                                       ubi-9-appstream-rpms
bash-5.1$ yum --showduplicates list python3.12-cryptography
Last metadata expiration check: 0:04:01 ago on Thu Sep 19 17:10:30 2024.
Available Packages
python3.12-cryptography.x86_64                                                                       41.0.7-1.el9                                                                       ubi-9-appstream-rpms

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the commit c42e6b6 to fix the vulnerabilities issues that are reported in the above comment. Using the updated Pipfile and Pipfile.lock to generate the different requirements files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop c42e6b6 whenever we pull in the changes from upstream after operator-framework/ansible-operator-plugins#92 is merged.

Copy link
Member Author

@arkadeepsen arkadeepsen Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the Pipfile to pin urllib3 version to 2.31.0 because of this issue:

The requirements.txt file is also updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the Pipfile to pin urllib3 version to 2.31.0 because of this issue:

Did you mean requests = "==2.31.0"? Because urllib3 is at urllib3 = "~=1.26.19"
https://github.com/openshift/ansible-operator-plugins/pull/20/files#diff-85c2285c39846cfb1ab26c4373213d7c91c4705e10d590b41c4d9503127fe812L10-L12

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. My bad. It's requests package which is pinned to 2.31.0.

@arkadeepsen arkadeepsen force-pushed the ansible-core branch 7 times, most recently from 560c156 to 94d4d98 Compare September 20, 2024 15:01
@TrilokGeer
Copy link

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2024
@chiragkyal
Copy link
Member

chiragkyal commented Sep 24, 2024

Adding some documentation with the steps to update the requirements or changing the dependent packages would help.

…mage

Add Dockerfile.requirements for generating the requirements.txt and requirments-build.txt files from the upstream Pipfile
Add make target to generate the requirements Add make target to check if the current requirements.txt and requirements-build.txt files are up-to-date
Update Dockerfile to use cachito specific env vars for installing the python modules using pip
Remove unused shell scripts and inline the user creation script in the Dockerfile
Update base images to rhel9 in Dockerfile
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2024
@arkadeepsen
Copy link
Member Author

/hold Until all the rpm packages are finalized.

/hold cancel
Removing the hold as the rpm packages are finalized.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 24, 2024
@TrilokGeer
Copy link

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2024
Copy link

openshift-ci bot commented Sep 24, 2024

@arkadeepsen: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Member

@KeenonLee KeenonLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Sep 25, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 25, 2024

@arkadeepsen: This pull request references CFE-1124 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.18.0" version, but no target version was set.

In response to this:

Description of the change:
This PR updates the Dockerfile to use pip instead of rpm to install ansible dependencies.

Following changes are made in this PR:

  • Add Dockerfile.requirements for generating the requirements.txt and requirments-build.txt files from the upstream Pipfile
  • Add make target to generate the requirements. Add make target to check if the current requirements.txt and requirements-build.txt files are up-to-date
  • Update Dockerfile to use cachito speicific env vars for installing the python modules using pip
  • Remove unused shell scripts and inline the user creation script in the Dockerfile
  • Update base images to rhel9 in Dockerfile

Motivation for the change:

In rhel8, ansible-core rpm uses python3.12, while the other ansible dependencies (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) use python3.6. This is causing ansible-runner to not find ansible during runtime of the operator created using the ansible-operator base image.

In rhel9, the various dependencies of ansible (ansible-runner, ansible-runner-http, python3-kubenetes, python3-openshit) will not be available as part of rpm packages.

For the above reasons ansible is being installed using pip instead of rpm.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-bot openshift-merge-bot bot merged commit d31f0a9 into openshift:main Sep 25, 2024
5 checks passed
@arkadeepsen
Copy link
Member Author

/cherrypick release-4.17

@openshift-cherrypick-robot

@arkadeepsen: new pull request created: #21

In response to this:

/cherrypick release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

Distgit: openshift-enterprise-ansible-operator
This PR has been included in build openshift-enterprise-ansible-operator-container-v4.18.0-202409250812.p0.gd31f0a9.assembly.stream.el9.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants