Skip to content

Recent updates to 3.9 and 3.7 images led to issue with SSL module during pip deps installation #787

Closed

Description

@CarpathianUA

image

WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
[1033][2023-01-19 09:56:22] Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

3.9.15 and 3.7.15 images aren't affected

Activity

  1. changed the title [-]Recent updated to 3.9 and 3.7 images led to issue with SSL module during pip deps installation[/-] [+]Recent updates to 3.9 and 3.7 images led to issue with SSL module during pip deps installation[/+] on Jan 19, 2023
  2. POD666 commented on Jan 19, 2023

    @POD666

    To be more specific, the issue seems to be related to our custom kaniko image. When building with docker build .. no issue was detected.

    The issue is definitely related to some recent changes in python:3.9 and python:3.7 images, until yesterday everything worked as expected. Alpine images work fine even after the recent changes.

  3. tianon commented on Jan 19, 2023

    @tianon
    Member

    Is there a particular reason you're building the image yourself instead of using the pre-built images? (the pre-built images work fine, right?)

  4. CarpathianUA commented on Jan 19, 2023

    @CarpathianUA
    Author

    @tianon We use pre-built images like python:3.9 as a base layer for our custom imagse

  5. tianon commented on Jan 19, 2023

    @tianon
    Member

    Hmm, that's weird -- all that's changed recently is #785, which shouldn't affect TLS, so I wonder what Kaniko is doing that's causing that to misbehave? 🤔 (unfortunately I don't actually know very much about Kaniko 🙈)

  6. POD666 commented on Jan 19, 2023

    @POD666

    I have no deep understanding on how kaniko works but I will try to explain with my words:

    • kaniko is based on scratch image by default, so it allows to build any images with any FROM statement.
    • after we created custom kaniko image, we had issues building images that are not on the same "base" as our custom kaniko image
    • I guess some path changes -rpath='$\$ORIGIN/../lib' lead to some conflicts between our custom kaniko image and the new python:3.9 image, but not sure why python:3.9-alpine works fine
    • side effect looks like a missing library for SSL. Maybe other libs are missing too.

    For anyone else who encounter such issue with custom kaniko - you could use previous python:3.9.15 image.

  7. tianon commented on Jan 19, 2023

    @tianon
    Member

    Do you have a small reproducer? @yosifkit is playing with kaniko now and pip install xxx is working fine for him 😅

  8. POD666 commented on Jan 20, 2023

    @POD666

    Yes, here is a script to reproduce:

    echo "
    FROM gcr.io/kaniko-project/executor:v1.8.1-debug as kaniko
    FROM docker:20.10.6
    # Add kaniko binary
    COPY --from=kaniko /kaniko/executor /kaniko/
    # we install a lot of additional tools&packages but the issue is reproduced without them
    " > Dockerfile.custom-kaniko
    
    docker build -t custom-kaniko - < Dockerfile.custom-kaniko
    
    # this works with python:3.9.15
    docker run --rm -it custom-kaniko sh -c 'echo "FROM python:3.9.15" > Dockerfile.test-image; echo "RUN pip install -U pip" >> Dockerfile.test-image; /kaniko/executor --dockerfile Dockerfile.test-image --no-push;'
    
    # this fails with python:3.9
    # Could not fetch URL https://pypi.org/simple/pip/:
    #    There was a problem confirming the ssl certificate:
    #    HTTPSConnectionPool(host='pypi.org', port=443):
    #       Max retries exceeded with url: /simple/pip/ (
    #            Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")
    #       ) - skipping
    docker run --rm -it custom-kaniko sh -c 'echo "FROM python:3.9" > Dockerfile.test-image; echo "RUN pip install -U pip" >> Dockerfile.test-image; /kaniko/executor --dockerfile Dockerfile.test-image --no-push;'
    
  9. albertok commented on Jan 20, 2023

    @albertok

    Started having the same issue yesterday as well.

    WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")'
    

    Can build with Docker builder fine but pip and python complain about SSL modules under Kaniko.

    Added the following to the Dockerfile to try and get more info on the state of ssl module.
    RUN python -c "import ssl; print(ssl.get_default_verify_paths())"

    With the following output when running in Kaniko.

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/lib/python3.7/ssl.py", line 98, in <module>
        import _ssl             # if we can't import it, let the error propagate
    ImportError: /usr/local/lib/python3.7/lib-dynload/_ssl.cpython-37m-x86_64-linux-gnu.so: undefined symbol: COMP_get_type, version OPENSSL_1_1_0
    error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
    

    Issue seems to coincide with 2592ad8

  10. yosifkit commented on Jan 20, 2023