fnproject / cli

CLI tool for fnproject.
https://fnproject.io
Apache License 2.0
132 stars 66 forks source link

Help needed to understand error message: Container failed to initialize, please ensure you are using the latest fdk and check the logs #684

Open HenrikBach1 opened 5 months ago

HenrikBach1 commented 5 months ago

Hi

I'm following your tutorial for hotwrap. Previously, I've followed it successfully. However, now I get an error message with: Container failed to initialize, please ensure you are using the latest fdk and check the logs:

sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn list functions revapp
NAME    IMAGE                   ID
revfunc sad/revfunc:0.0.1       01J06M3B3WNG8G00GZJ0000004
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn delete function revapp revfunc
Function revfunc deleted
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn delete app revapp 
App revapp deleted
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn --verbose build
Using Container engine docker
Building image sad/revfunc:0.0.1 
Dockerfile content
-----------------------------------
FROM alpine:latest

# Install hotwrap binary in your container
COPY --from=fnproject/hotwrap:latest  /hotwrap /hotwrap

CMD "/bin/rev"

ENTRYPOINT ["/hotwrap"]
-----------------------------------
FN_REGISTRY:  sad
Current Context:  default
[+] Building 0.9s (8/8) FINISHED                                                                                                                                                                          docker:default
 => [internal] load .dockerignore                                                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                                                     0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                0.0s
 => => transferring dockerfile: 199B                                                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                    0.8s
 => [internal] load metadata for docker.io/fnproject/hotwrap:latest                                                                                                                                                 0.8s
 => FROM docker.io/fnproject/hotwrap:latest@sha256:bf6303d7d216581c0e760f33dd74c3cdea83edad69f3d9614b7f573ba62c22b4                                                                                                 0.0s
 => [stage-0 1/2] FROM docker.io/library/alpine:latest@sha256:77726ef6b57ddf65bb551896826ec38bc3e53f75cdde31354fbffb4f25238ebd                                                                                      0.0s
 => CACHED [stage-0 2/2] COPY --from=fnproject/hotwrap:latest  /hotwrap /hotwrap                                                                                                                                    0.0s
 => exporting to image                                                                                                                                                                                              0.0s
 => => exporting layers                                                                                                                                                                                             0.0s
 => => writing image sha256:694eaa4c562a9a27e5ee02260de6de37775a95e87814a6f7761baf2eb6a1691d                                                                                                                        0.0s
 => => naming to docker.io/sad/revfunc:0.0.1                                                                                                                                                                        0.0s

Function sad/revfunc:0.0.1 built successfully.
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn list functions revapp

Fn: app revapp not found

See 'fn <command> --help' for more information. Client version: 0.6.34
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn list apps
NAME            ID
cvechecker      01J06CX48ANG8G00GZJ0000001
testapp         01J05GSJ3FNG8G00GZJ0000004
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn create app revapp
Successfully created app:  revapp
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn deploy --app revapp --local --no-bump
Deploying revfunc to app: revapp
Using Container engine docker
Building image sad/revfunc:0.0.1 .
Updating function revfunc using image sad/revfunc:0.0.1...
Successfully created function: revfunc with sad/revfunc:0.0.1
Successfully created trigger: revfunc
Trigger Endpoint: http://localhost:8080/t/revapp/revfunc
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ fn list functions revapp
NAME    IMAGE                   ID
revfunc sad/revfunc:0.0.1       01J088Q1D4NG8G00RZJ0000004
sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ curl --data "Hello World" -H "Content-Type: text/plain" -X POST http://localhost:8080/t/revapp/revfunc
time="2024-06-13T07:42:57Z" level=info msg="hot function terminated" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J088SFM2NG8G00RZJ0000007 cpus= error="container exit code 1" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:42:57Z" level=info msg="hot function failure" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J088SFM2NG8G00RZJ0000007 cpus= error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:42:57Z" level=info msg="container wait error, sending error to client" action="server.handleHTTPTriggerCall)-fm" app_id=01J08894CFNG8G00RZJ0000003 app_name=revapp call_id=01J088SFM2NG8G00RZJ0000006 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004 trigger_source=/revfunc
time="2024-06-13T07:42:57Z" level=error msg="api error" action="server.handleHTTPTriggerCall)-fm" app_name=revapp code=502 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" trigger_source=/revfunc
{"message":"Container failed to initialize, please ensure you are using the latest fdk and check the logs"}

The fnserver was started without debug log level: fn start and the complete log from fnserver is:

Script started on 2024-06-13 10:02:35+02:00 [COMMAND="docker logs fnserver" TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="103" LINES="53"]
time="2024-06-13T07:04:24Z" level=info msg="Setting log level to" fields.level=info
time="2024-06-13T07:04:24Z" level=info msg="Registering data store provider 'sql'"
time="2024-06-13T07:04:24Z" level=info msg="Connecting to DB" url="sqlite3:///app/data/fn.db"
time="2024-06-13T07:04:24Z" level=info msg="datastore dialed" datastore=sqlite3 max_idle_connections=256 url="sqlite3:///app/data/fn.db"
time="2024-06-13T07:04:24Z" level=info msg="agent starting cfg={MinDockerVersion:17.10.0-ce ContainerLabelTag: DockerNetworks: DockerLoadFile: DisableUnprivilegedContainers:false FreezeIdle:50ms HotPoll:200ms HotLauncherTimeout:1h0m0s HotPullTimeout:10m0s HotStartTimeout:5s DetachedHeadRoom:6m0s MaxResponseSize:0 MaxHdrResponseSize:0 MaxLogSize:1048576 MaxTotalCPU:0 MaxTotalMemory:0 MaxFsSize:0 MaxPIDs:50 MaxOpenFiles:0xc420212b98 MaxLockedMemory:0xc420212bb0 MaxPendingSignals:0xc420212bb8 MaxMessageQueue:0xc420212bc0 PreForkPoolSize:0 PreForkImage:busybox PreForkCmd:tail -f /dev/null PreForkUseOnce:0 PreForkNetworks: EnableNBResourceTracker:false MaxTmpFsInodes:0 DisableReadOnlyRootFs:false DisableDebugUserLogs:false IOFSEnableTmpfs:false EnableFDKDebugInfo:false IOFSAgentPath:/iofs IOFSMountRoot:/home/sad/.fn/iofs IOFSOpts: ImageCleanMaxSize:0 ImageCleanExemptTags: ImageEnableVolume:false}"
time="2024-06-13T07:04:24Z" level=info msg="no docker auths from config files found (this is fine)" error="open /root/.dockercfg: no such file or directory"
time="2024-06-13T07:04:24Z" level=error msg="Error checking for cgroup memory limits, falling back to host memory available.." error="open /sys/fs/cgroup/memory/memory.limit_in_bytes: no such file or directory"
time="2024-06-13T07:04:24Z" level=info msg="available memory" cgroup_limit=0 head_room=2927506636 total_memory=29275066368
time="2024-06-13T07:04:24Z" level=info msg="ram reservations" avail_memory=26347559732
time="2024-06-13T07:04:24Z" level=info msg="available cpu" avail_cpu=8000 total_cpu=8000
time="2024-06-13T07:04:24Z" level=info msg="cpu reservations" cpu=8000
time="2024-06-13T07:04:24Z" level=info msg="\n        ______\n       / ____/___\n      / /_  / __ \\\n     / __/ / / / /\n    /_/   /_/ /_/\n"
time="2024-06-13T07:04:24Z" level=info msg="Fn serving on `:8080`" type=full version=0.3.750
time="2024-06-13T07:04:44Z" level=info msg="hot function terminated" app_id=01J06M27R7NG8G00GZJ0000003 container_id=01J086KFY4NG8G00RZJ0000002 cpus= error="container exit code 1" fn_id=01J06M3B3WNG8G00GZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:04:44Z" level=info msg="hot function failure" app_id=01J06M27R7NG8G00GZJ0000003 container_id=01J086KFY4NG8G00RZJ0000002 cpus= error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J06M3B3WNG8G00GZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:04:44Z" level=info msg="container wait error, sending error to client" action="server.handleHTTPTriggerCall)-fm" app_id=01J06M27R7NG8G00GZJ0000003 app_name=revapp call_id=01J086KFY4NG8G00RZJ0000001 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J06M3B3WNG8G00GZJ0000004 trigger_source=/revfunc
time="2024-06-13T07:04:44Z" level=error msg="api error" action="server.handleHTTPTriggerCall)-fm" app_name=revapp code=502 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" trigger_source=/revfunc
time="2024-06-13T07:42:57Z" level=info msg="hot function terminated" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J088SFM2NG8G00RZJ0000007 cpus= error="container exit code 1" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:42:57Z" level=info msg="hot function failure" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J088SFM2NG8G00RZJ0000007 cpus= error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T07:42:57Z" level=info msg="container wait error, sending error to client" action="server.handleHTTPTriggerCall)-fm" app_id=01J08894CFNG8G00RZJ0000003 app_name=revapp call_id=01J088SFM2NG8G00RZJ0000006 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004 trigger_source=/revfunc
time="2024-06-13T07:42:57Z" level=error msg="api error" action="server.handleHTTPTriggerCall)-fm" app_name=revapp code=502 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" trigger_source=/revfunc

Script done on 2024-06-13 10:02:35+02:00 [COMMAND_EXIT_CODE="0"]

What am i doing wrong?

I've attached my used Dockerfile and func.yaml files to this post as *.txt files: func.yaml.txt Dockerfile.txt

Regards Henrik

HenrikBach1 commented 5 months ago

I use the latest fn client and server:

Script started on 2024-06-13 10:17:16+02:00 [COMMAND="fn version" TERM="xterm-256color" TTY="/dev/pts/1" COLUMNS="103" LINES="12"]
Client version is latest version: 0.6.34
Server version:  0.3.750

Script done on 2024-06-13 10:17:17+02:00 [COMMAND_EXIT_CODE="0"]
HenrikBach1 commented 5 months ago

Using echo in the invoke of the revfunc gives a similar result:

sad@sad-HP-ZBook-17-G2:~/projects/fn/revfunc$ echo "Hello World" | fn invoke revapp revfunc
time="2024-06-13T08:21:01Z" level=info msg="hot function terminated" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J08AZ5RYNG8G00RZJ0000009 cpus= error="container exit code 1" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T08:21:01Z" level=info msg="hot function failure" app_id=01J08894CFNG8G00RZJ0000003 container_id=01J08AZ5RYNG8G00RZJ0000009 cpus= error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004 idle_timeout=30 image="sad/revfunc:0.0.1" memory=128
time="2024-06-13T08:21:01Z" level=info msg="container wait error, sending error to client" action="server.handleFnInvokeCall)-fm" app_id=01J08894CFNG8G00RZJ0000003 call_id=01J08AZ5RYNG8G00RZJ0000008 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004
time="2024-06-13T08:21:01Z" level=error msg="api error" action="server.handleFnInvokeCall)-fm" code=502 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J088Q1D4NG8G00RZJ0000004
Error invoking function. status: 502 message: Container failed to initialize, please ensure you are using the latest fdk and check the logs
dick-twocows commented 4 months ago

Can verify that I have the same issue with the hotfunc revfunc...

time="2024-07-15T19:10:26Z" level=info msg="Fn serving on `:8080`" type=full version=0.3.750
time="2024-07-15T19:10:34Z" level=info msg="hot function terminated" app_id=01J2VVNWATNG8G00GZJ0000001 container_id=01J2VWVGGQNG8G00GZJ0000002 cpus= error="container exit code 1" fn_id=01J2VVPCYPNG8G00GZJ0000002 idle_timeout=30 image="revfunc:0.0.1" memory=128
time="2024-07-15T19:10:34Z" level=info msg="hot function failure" app_id=01J2VVNWATNG8G00GZJ0000001 container_id=01J2VWVGGQNG8G00GZJ0000002 cpus= error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J2VVPCYPNG8G00GZJ0000002 idle_timeout=30 image="revfunc:0.0.1" memory=128
time="2024-07-15T19:10:34Z" level=info msg="container wait error, sending error to client" action="server.handleFnInvokeCall)-fm" app_id=01J2VVNWATNG8G00GZJ0000001 call_id=01J2VWVGGQNG8G00GZJ0000001 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J2VVPCYPNG8G00GZJ0000002
time="2024-07-15T19:10:34Z" level=error msg="api error" action="server.handleFnInvokeCall)-fm" code=502 error="Container failed to initialize, please ensure you are using the latest fdk and check the logs" fn_id=01J2VVPCYPNG8G00GZJ0000002
helper/scratch/rev on  main [!?] via 🐳 rancher-desktop 
❯ echo "Hello World" | fn invoke revapp revfunc
Error invoking function. status: 502 message: Container failed to initialize, please ensure you are using the latest fdk and check the logs

helper/scratch/rev on  main [!?] via 🐳 rancher-desktop 
❯ curl --data "Hello World" -H "Content-Type: text/plain" -X POST http://localhost:8080/t/revapp/revfunc
{"message":"Container failed to initialize, please ensure you are using the latest fdk and check the logs"}