func icon indicating copy to clipboard operation
func copied to clipboard

func python - Address family not supported by protocol

Open kkpuetz opened this issue 2 months ago • 1 comments

Working on the bookstore example sentiment-analysis-app although it's happening with any python func I try running on a k3s cluster.

building for linux/amd64 from MacOs

func deploy -b=s2i --platform linux/amd64 -v

image builds successfully but pod errors on what appears to be an issue on func python enforcing ipv6 sockets which is not enabled on the ubuntu node vms.

Waiting for Knative Service to become ready
---> Running application from script (app.sh) ...
INFO:root:Functions middleware invoking user function
INFO:root:function does not implement 'alive'. Using default implementation for liveness checks.
INFO:root:function does not implement 'ready'. Using default implementation for readiness checks.
INFO:root:function does not implement 'start'. Skipping.
Traceback (most recent call last):
  File "/opt/app-root/src/.s2i/builds/last/service/main.py", line 23, in <module>
    serve(handler)
  File "/opt/app-root/lib64/python3.9/site-packages/func_python/http.py", line 23, in serve
    return ASGIApplication(f()).serve()
  File "/opt/app-root/lib64/python3.9/site-packages/func_python/http.py", line 75, in serve
    return asyncio.run(self._serve(cfg))
  File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/opt/app-root/lib64/python3.9/site-packages/func_python/http.py", line 82, in _serve
    await hypercorn.asyncio.serve(self, cfg)
  File "/opt/app-root/lib64/python3.9/site-packages/hypercorn/asyncio/__init__.py", line 44, in serve
    await worker_serve(
  File "/opt/app-root/lib64/python3.9/site-packages/hypercorn/asyncio/run.py", line 91, in worker_serve
    sockets = config.create_sockets()
  File "/opt/app-root/lib64/python3.9/site-packages/hypercorn/config.py", line 206, in create_sockets
    insecure_sockets = self._create_sockets(self.bind)
  File "/opt/app-root/lib64/python3.9/site-packages/hypercorn/config.py", line 248, in _create_sockets
    sock = socket.socket(socket.AF_INET6 if ":" in host else socket.AF_INET, type_)
  File "/usr/lib64/python3.9/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol

kn version Version: v1.19.5 func version v0.46.4

Need some help determining if this is an intended limitation or if there are vars that can be set to enable this to work on ipv4 only supported nodes.

kkpuetz avatar Oct 23 '25 18:10 kkpuetz

I was able to get it built by adding this to func.yaml

run:
  envs:
  - name: LISTEN_ADDRESS
    value: 0.0.0.0:8080

after tracking down https://github.com/knative-extensions/func-python/blob/11fea5d5b27a69a05d41f3b4520d53c78ee157dc/src/func_python/cloudevent.py#L77

kkpuetz avatar Oct 24 '25 18:10 kkpuetz

I'll look at this.

matejvasek avatar Nov 11 '25 13:11 matejvasek

@kkpuetz I am working on fix.

See: https://github.com/knative-extensions/func-python/pull/66 It shall take effect upon publishing to PyPI.

You can however build func using the PR src code and test it now:

diff --git a/templates/python/scaffolding/instanced-cloudevents/pyproject.toml b/templates/python/scaffolding/instanced-cloudevents/pyproject.toml
index 8cb97884..643ced24 100644
--- a/templates/python/scaffolding/instanced-cloudevents/pyproject.toml
+++ b/templates/python/scaffolding/instanced-cloudevents/pyproject.toml
@@ -6,7 +6,7 @@ requires-python = ">=3.9"
 readme = "README.md"
 license = "MIT"
 dependencies = [
-    "func-python",
+    "func-python @ git+https://github.com/knative-extensions/func-python.git@43ef8e0e5aa5ab89ca0cd595dacbeed662a8bf37",
     "function @ {root:uri}/f"
 ]
 authors = [
diff --git a/templates/python/scaffolding/instanced-http/pyproject.toml b/templates/python/scaffolding/instanced-http/pyproject.toml
index 8cb97884..643ced24 100644
--- a/templates/python/scaffolding/instanced-http/pyproject.toml
+++ b/templates/python/scaffolding/instanced-http/pyproject.toml
@@ -6,7 +6,7 @@ requires-python = ">=3.9"
 readme = "README.md"
 license = "MIT"
 dependencies = [
-    "func-python",
+    "func-python @ git+https://github.com/knative-extensions/func-python.git@43ef8e0e5aa5ab89ca0cd595dacbeed662a8bf37",
     "function @ {root:uri}/f"
 ]
 authors = [

I prebuilt func binaries for you: https://filebin.net/uo1suz7jtt0l08xx

I don't know how much I can trust filebin.net, the archive should contain gpg signature so definitely verify it's signed by me (https://github.com/matejvasek.gpg) and sums matches.

gpg --verify --assert-signer=A9488F41395B399DD3069A3C72036E3FC07BF8F1 sum.txt.asc
sha256sum -c sum.txt

matejvasek avatar Nov 17 '25 16:11 matejvasek