OpenFunction/samples

Sample function Python fails to build: dial tcp 216.58.215.174:443: i/o timeout [id:65f44802]

Altair-Bueno opened this issue · 2 comments

Following the sample instructions: https://github.com/OpenFunction/samples/tree/main/functions/knative/hello-world-python

$ sudo pack build python-sample --builder openfunction/gcp-builder:v1 --env GOOGLE_FUNCTION_TARGET=hello_world
v1: Pulling from openfunction/gcp-builder
Digest: sha256:3c059c0cc83c98b43fc947f470162720a7b59dd45a7dd38af1c1f4ee54a24794
Status: Image is up to date for openfunction/gcp-builder:v1
v1: Pulling from buildpacks/gcp/run
Digest: sha256:4ba3727b3c1527ecb81e5e84db9447fd955859868c52d7b41bca97a1f6df4b9b
Status: Image is up to date for gcr.io/buildpacks/gcp/run:v1
0.13.3: Pulling from buildpacksio/lifecycle
Digest: sha256:9d194fc3997e8c448473431433908d932cd359b10b270f2b0f76ec795c8cae28
Status: Image is up to date for buildpacksio/lifecycle:0.13.3
===> ANALYZING
[analyzer] Previous image with name "python-sample" not found
===> DETECTING
[detector] 4 of 5 buildpacks participating
[detector] google.python.runtime             0.9.1
[detector] google.python.functions-framework 0.9.6
[detector] google.python.pip                 0.9.2
[detector] google.utils.label                0.0.2
===> RESTORING
===> BUILDING
[builder] === Python - Runtime (google.python.runtime@0.9.1) ===
[builder] Python version not specified, using the test available version.
[builder] 2022/12/02 10:17:02 [DEBUG] GET https://dl.google.com/runtimes/python/version.json
[builder] 2022/12/02 10:17:32 [ERR] GET https://dl.google.com/runtimes/python/version.json request failed: Get "https://dl.google.com/runtimes/python/version.json": dial tcp 216.58.215.174:443: i/o timeout
[builder] 2022/12/02 10:17:32 [DEBUG] GET https://dl.google.com/runtimes/python/version.json: retrying in 1s (3 left)
[builder] 2022/12/02 10:18:03 [ERR] GET https://dl.google.com/runtimes/python/version.json request failed: Get "https://dl.google.com/runtimes/python/version.json": dial tcp 216.58.215.174:443: i/o timeout
[builder] 2022/12/02 10:18:03 [DEBUG] GET https://dl.google.com/runtimes/python/version.json: retrying in 2s (2 left)
[builder] 2022/12/02 10:18:35 [ERR] GET https://dl.google.com/runtimes/python/version.json request failed: Get "https://dl.google.com/runtimes/python/version.json": dial tcp 216.58.215.174:443: i/o timeout
[builder] 2022/12/02 10:18:35 [DEBUG] GET https://dl.google.com/runtimes/python/version.json: retrying in 4s (1 left)
[builder] 2022/12/02 10:19:09 [ERR] GET https://dl.google.com/runtimes/python/version.json request failed: Get "https://dl.google.com/runtimes/python/version.json": dial tcp 216.58.215.174:443: i/o timeout
[builder] Failure: (ID: a800fcc9) fetching Python versions: requesting https://dl.google.com/runtimes/python/version.json: Get "https://dl.google.com/runtimes/python/version.json": GET https://dl.google.com/runtimes/python/version.json giving up after 4 attempt(s): Get "https://dl.google.com/runtimes/python/version.json": dial tcp 216.58.215.174:443: i/o timeout [id:65f44802]
[builder] --------------------------------------------------------------------------------
[builder] Sorry your project couldn't be built.
[builder] Our documentation explains ways to configure Buildpacks to better recognise your project:
[builder]  -> https://github.com/GoogleCloudPlatform/buildpacks/blob/main/README.md
[builder] If you think you've found an issue, please report it:
[builder]  -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
[builder] --------------------------------------------------------------------------------
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51

The machine is able to connect to https://dl.google.com/runtimes/python/version.json, but a 404 page is returned

$ curl https://dl.google.com/runtimes/python/version.json

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>  <ins>That’s all we know.</ins>

Works fine in my environment, cannot reproduce:

pack build python-sample --builder openfunction/gcp-builder:v1 --env GOOGLE_FUNCTION_TARGET=hello_world
v1: Pulling from openfunction/gcp-builder
Digest: sha256:3c059c0cc83c98b43fc947f470162720a7b59dd45a7dd38af1c1f4ee54a24794
Status: Image is up to date for openfunction/gcp-builder:v1
v1: Pulling from buildpacks/gcp/run
Digest: sha256:4ba3727b3c1527ecb81e5e84db9447fd955859868c52d7b41bca97a1f6df4b9b
Status: Image is up to date for gcr.io/buildpacks/gcp/run:v1
0.13.3: Pulling from buildpacksio/lifecycle
Digest: sha256:9d194fc3997e8c448473431433908d932cd359b10b270f2b0f76ec795c8cae28
Status: Image is up to date for buildpacksio/lifecycle:0.13.3
===> ANALYZING
[analyzer] Previous image with name "python-sample" not found
===> DETECTING
[detector] 4 of 5 buildpacks participating
[detector] google.python.runtime             0.9.1
[detector] google.python.functions-framework 0.9.6
[detector] google.python.pip                 0.9.2
[detector] google.utils.label                0.0.2
===> RESTORING
===> BUILDING
[builder] === Python - Runtime (google.python.runtime@0.9.1) ===
[builder] Python version not specified, using the test available version.
[builder] 2022/12/06 02:18:48 [DEBUG] GET https://dl.google.com/runtimes/python/version.json
[builder] Installing Python v3.10.5.
[builder] 2022/12/06 02:18:49 [DEBUG] GET https://dl.google.com/runtimes/python/python-3.10.5.tar.gz
[builder] Upgrading pip to the latest version and installing build tools
[builder] --------------------------------------------------------------------------------
[builder] Running "/layers/google.python.runtime/python/bin/python3 -m pip install --upgrade pip setuptools wheel"
[builder] Requirement already satisfied: pip in /layers/google.python.runtime/python/lib/python3.10/site-packages (22.0.4)
[builder] Collecting pip
[builder]   Downloading pip-22.3.1-py3-none-any.whl (2.1 MB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 5.4 MB/s eta 0:00:00
[builder] Requirement already satisfied: setuptools in /layers/google.python.runtime/python/lib/python3.10/site-packages (58.1.0)
[builder] Collecting setuptools
[builder]   Downloading setuptools-65.6.3-py3-none-any.whl (1.2 MB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 13.2 MB/s eta 0:00:00
[builder] Collecting wheel
[builder]   Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
[builder] Installing collected packages: wheel, setuptools, pip
[builder]   Attempting uninstall: setuptools
[builder]     Found existing installation: setuptools 58.1.0
[builder]     Uninstalling setuptools-58.1.0:
[builder]       Successfully uninstalled setuptools-58.1.0
[builder]   Attempting uninstall: pip
[builder]     Found existing installation: pip 22.0.4
[builder]     Uninstalling pip-22.0.4:
[builder]       Successfully uninstalled pip-22.0.4
[builder] Successfully installed pip-22.3.1 setuptools-65.6.3 wheel-0.38.4
[builder] Done "/layers/google.python.runtime/python/bin/python3 -m pip inst..." (13.052782332s)
[builder] === Python - Functions Framework (google.python.functions-framework@0.9.6) ===
[builder] --------------------------------------------------------------------------------
[builder] Running "python3 -m compileall -f -q ."
[builder] Done "python3 -m compileall -f -q ." (119.422341ms)
[builder] Handling functions with dependency on functions-framework.
[builder] WARNING: Launch layer is setting default=true, but that is not supported until API version 0.6. This setting will be ignored.
[builder] Warning: Warning: default processes aren't supported in this buildpack api version. Overriding the default value to false for the following processes: [web]
[builder] === Python - pip (google.python.pip@0.9.2) ===
[builder] Installing application dependencies.
[builder] --------------------------------------------------------------------------------
[builder] Running "python3 -m pip install --requirement requirements.txt --upgrade --upgrade-strategy only-if-needed --no-warn-script-location --no-warn-conflicts --force-reinstall --no-compile --user (PIP_CACHE_DIR=/layers/google.python.pip/pipcache PIP_DISABLE_PIP_VERSION_CHECK=1)"
[builder] Collecting functions-framework==1.4.3
[builder]   Downloading functions_framework-1.4.3-py3-none-any.whl (21 kB)
[builder] Collecting markupsafe==2.0.1
[builder]   Downloading MarkupSafe-2.0.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
[builder] Collecting click<8.0,>=7.0
[builder]   Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.8/82.8 kB 904.9 kB/s eta 0:00:00
[builder] Collecting flask<2.0,>=1.0
[builder]   Downloading Flask-1.1.4-py2.py3-none-any.whl (94 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 94.6/94.6 kB 1.5 MB/s eta 0:00:00
[builder] Collecting gunicorn<21.0,>=19.2.0
[builder]   Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.5/79.5 kB 1.6 MB/s eta 0:00:00
[builder] Collecting watchdog>=0.10.0
[builder]   Downloading watchdog-2.2.0-py3-none-manylinux2014_x86_64.whl (78 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.7/78.7 kB 1.1 MB/s eta 0:00:00
[builder] Collecting Werkzeug<2.0,>=0.15
[builder]   Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 298.6/298.6 kB 2.9 MB/s eta 0:00:00
[builder] Collecting itsdangerous<2.0,>=0.24
[builder]   Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
[builder] Collecting Jinja2<3.0,>=2.10.1
[builder]   Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.7/125.7 kB 3.0 MB/s eta 0:00:00
[builder] Collecting setuptools>=3.0
[builder]   Downloading setuptools-65.6.3-py3-none-any.whl (1.2 MB)
[builder]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 10.0 MB/s eta 0:00:00
[builder] Installing collected packages: Werkzeug, watchdog, setuptools, markupsafe, itsdangerous, click, Jinja2, gunicorn, flask, functions-framework
[builder] Successfully installed Jinja2-2.11.3 Werkzeug-1.0.1 click-7.1.2 flask-1.1.4 functions-framework-1.4.3 gunicorn-20.1.0 itsdangerous-1.1.0 markupsafe-2.0.1 setuptools-65.6.3 watchdog-2.2.0
[builder] Done "python3 -m pip install --requirement requirements.txt --upgr..." (7.161018115s)
[builder] --------------------------------------------------------------------------------
[builder] Running "python3 -m compileall --invalidation-mode unchecked-hash -qq /layers/google.python.pip/pip"
[builder] Done "python3 -m compileall --invalidation-mode unchecked-hash -qq..." (1.978735884s)
[builder] Checking for incompatible dependencies.
[builder] --------------------------------------------------------------------------------
[builder] Running "python3 -m pip check"
[builder] No broken requirements found.
[builder] Done "python3 -m pip check" (1.082849238s)
[builder] === Utils - Label Image (google.utils.label@0.0.2) ===
===> EXPORTING
[exporter] Adding layer 'google.python.runtime:python'
[exporter] Adding layer 'google.python.functions-framework:functions-framework'
[exporter] Adding layer 'google.python.pip:pip'
[exporter] Adding 1/1 app layer(s)
[exporter] Adding layer 'launcher'
[exporter] Adding layer 'config'
[exporter] Adding layer 'process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] Setting default process type 'web'
[exporter] Saving python-sample...
[exporter] *** Images (1c147163077f):
[exporter]       python-sample
[exporter] Adding cache layer 'google.python.runtime:python'
[exporter] Adding cache layer 'google.python.pip:pip'
[exporter] Adding cache layer 'google.python.pip:pipcache'
Successfully built image python-sample

You need to provide UA to access https://dl.google.com/runtimes/python/version.json:

curl -A GCPBuildpacks https://dl.google.com/runtimes/python/version.json
["3.10.0","3.10.1","3.10.2","3.10.3","3.10.4","3.10.5","3.7.0","3.7.1","3.7.10","3.7.11","3.7.12","3.7.13","3.7.2","3.7.3","3.7.4","3.7.5","3.7.6","3.7.7","3.7.8","3.7.9","3.8.0","3.8.1","3.8.10","3.8.11","3.8.12","3.8.13","3.8.2","3.8.3","3.8.4","3.8.5","3.8.6","3.8.7","3.8.8","3.8.9","3.9.0","3.9.1","3.9.10","3.9.11","3.9.12","3.9.13","3.9.2","3.9.3","3.9.4","3.9.5","3.9.6","3.9.7","3.9.8","3.9.9"]%

Check if your network access to https://dl.google.com/runtimes/python/version.json is restricted, not on the host but in the container.

Indeed was an issue on my Docker installation. Docker was using IPv6 instead of IPv4. Using --network host solves this issue

Thanks for your help, i would have never guessed that https://dl.google.com/runtimes/python/version.json requires an UA, thats kinda tricky to debug.