operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.25k stars 1.74k forks source link

Why does ansible-operator image contain files from python3.6 and python3.8 ? #6149

Closed simararneja closed 1 year ago

simararneja commented 2 years ago

Looking at the dive report for the quay.io/operator-framework/ansible-operator:v1.25.0 image I noticed there are duplicate files being baked into the docker image. The two directories in question are /usr/lib64/python3.6 and /usr/lib64/python3.8.

It appears the two folders are also baked inside https://github.com/operator-framework/operator-sdk/blob/master/images/ansible-operator/Dockerfile#L20

Do we need both the versions ? If not, then perhaps not include python 3.6 related files . This should reduce the image size ideally.

jmrodri commented 1 year ago

/usr/lib64/python3.8 is provided by python38-libs-3.8.13-1.module+el8.7.0+15641+2ece4388.x86_64.

If I try to remove python38-libs, that shows that it tries to remove python38-pip, which is a package we need to support pip calls.

Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.

This system is not registered with an entitlement server. You can use subscription-manager to register.

Dependencies resolved.
===================================================================================================================================================================================================================
 Package                                              Architecture                      Version                                                             Repository                                        Size
===================================================================================================================================================================================================================
Removing:
 python38-libs                                        x86_64                            3.8.13-1.module+el8.7.0+15641+2ece4388                              @ubi-8-appstream-rpms                             33 M
Removing dependent packages:
 python38                                             x86_64                            3.8.13-1.module+el8.7.0+15641+2ece4388                              @ubi-8-appstream-rpms                             24 k
 python38-pip                                         noarch                            19.3.1-6.module+el8.7.0+15823+8950cfa7                              @ubi-8-appstream-rpms                            7.4 M
 python38-setuptools                                  noarch                            41.6.0-5.module+el8.5.0+12205+a865257a                              @ubi-8-appstream-rpms                            2.9 M
Removing unused dependencies:
 python38-pip-wheel                                   noarch                            19.3.1-6.module+el8.7.0+15823+8950cfa7                              @ubi-8-appstream-rpms                            1.0 M
 python38-setuptools-wheel                            noarch                            41.6.0-5.module+el8.5.0+12205+a865257a                              @ubi-8-appstream-rpms                            352 k

Transaction Summary
===================================================================================================================================================================================================================
Remove  6 Packages

Freed space: 44 M
Is this ok [y/N]: n
Operation aborted.

Meanwhile, /usr/lib64/python3.6 is provided by python3-libs-3.6.8-48.el8_7.x86_64. If we try to remove that package, we end up trying to remove dnf. That's not a good idea either.

dnf remove python3-libs-3.6.8-48.el8_7.x86_64
Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.

This system is not registered with an entitlement server. You can use subscription-manager to register.

Error: 
 Problem: The operation would result in removing the following protected packages: dnf
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

At the moment, both are needed. If you'd like to help and look into reducing the size of this image, we'd love the help. Just reopen this issue or create a new one.

jmontleon commented 3 months ago

Why not use python3-pip instead of python38-pip and use the system python 3.6 instead of the python 3.8 module?

This creates a confusing inconsistency in the version of python used in the upstream image and downstream when installing dependencies from RPM packages. (https://catalog.redhat.com/software/containers/openshift4/ose-ansible-operator)