From 6375efdca6ccb9a6a2d11c36f82c18a082667d6d Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 28 Oct 2026 11:54:48 +0000 Subject: [PATCH 01/14] Update all runtimes --- pkg/docker/runtimes/go/Dockerfile | 7 +++++-- pkg/docker/runtimes/go/build.Dockerfile | 6 +++--- pkg/docker/runtimes/nodejs/build.Dockerfile | 5 ++--- pkg/docker/runtimes/python3/Dockerfile | 3 ++- pkg/docker/runtimes/python3/build.Dockerfile | 6 ++++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/pkg/docker/runtimes/go/Dockerfile b/pkg/docker/runtimes/go/Dockerfile index ada4897..70af26d 100644 --- a/pkg/docker/runtimes/go/Dockerfile +++ b/pkg/docker/runtimes/go/Dockerfile @@ -1,4 +1,7 @@ -FROM golang:1.22-alpine3.19 +ARG GO_VERSION=1.27.3 +ARG ALPINE_VERSION=3.24 + +FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} ADD blob.tar.gz / @@ -12,4 +15,4 @@ RUN CGO_ENABLED=0 go build -o handler . EXPOSE 8000 -CMD ["./handler"] \ No newline at end of file +CMD ["./handler"] diff --git a/pkg/docker/runtimes/go/build.Dockerfile b/pkg/docker/runtimes/go/build.Dockerfile index ebd8920..577b2ab 100644 --- a/pkg/docker/runtimes/go/build.Dockerfile +++ b/pkg/docker/runtimes/go/build.Dockerfile @@ -1,8 +1,8 @@ -ARG GO_VERSION=1.22 -ARG ALPINE_VERSION=3.19 +ARG GO_VERSION=1.27.3 +ARG ALPINE_VERSION=3.24 FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} WORKDIR /usr/src/app -COPY functionhandler.go ./ \ No newline at end of file +COPY functionhandler.go ./ diff --git a/pkg/docker/runtimes/nodejs/build.Dockerfile b/pkg/docker/runtimes/nodejs/build.Dockerfile index 8c3b9fb..9b50e90 100644 --- a/pkg/docker/runtimes/nodejs/build.Dockerfile +++ b/pkg/docker/runtimes/nodejs/build.Dockerfile @@ -1,6 +1,5 @@ -#https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ -ARG NODE_VERSION=20.14 -ARG ALPINE_VERSION=3.19 +ARG NODE_VERSION=26.12 +ARG ALPINE_VERSION=3.24 FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} diff --git a/pkg/docker/runtimes/python3/Dockerfile b/pkg/docker/runtimes/python3/Dockerfile index e89a94b..755c0d8 100644 --- a/pkg/docker/runtimes/python3/Dockerfile +++ b/pkg/docker/runtimes/python3/Dockerfile @@ -8,7 +8,8 @@ EXPOSE 8000 WORKDIR /usr/src/app COPY fn/* ./ -RUN python -m pip install -r requirements.txt --user + +RUN uv pip install --system --no-cache --link-mode=copy -r requirements.txt ENV PYTHONUNBUFFERED=1 CMD [ "python3", "functionhandler.py" ] diff --git a/pkg/docker/runtimes/python3/build.Dockerfile b/pkg/docker/runtimes/python3/build.Dockerfile index 79bf6ae..1352ab6 100644 --- a/pkg/docker/runtimes/python3/build.Dockerfile +++ b/pkg/docker/runtimes/python3/build.Dockerfile @@ -1,8 +1,10 @@ -ARG PYTHON_VERSION=3.11 -ARG ALPINE_VERSION=3.19 +ARG PYTHON_VERSION=3.13 +ARG ALPINE_VERSION=3.24 FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + # Create app directory WORKDIR /usr/src/app From 0bc77fef43522cd6a93e88b0108da181e44b7d85 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 10:28:38 +0000 Subject: [PATCH 02/14] Delete generated files with 'make clean' --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index af0ca88..8973c2b 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,8 @@ test: build ${TEST_DIR}/test_all.py pkg/grpc/tinyfaas/tinyfaas_pb2.py pkg/grpc/t .PHONY: clean clean: clean.sh @sh clean.sh + rm -rfv pkg/docker/runtimes-*/ + rm -fv tinyfaas-*-* cmd/manager/rproxy-*.bin define arch_build From 49a5619f1e9afbc5f9c86282752b10f7975a7ee6 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 28 Oct 2026 13:33:46 +0000 Subject: [PATCH 03/14] Update binary runtime --- pkg/docker/runtimes/binary/build.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/docker/runtimes/binary/build.Dockerfile b/pkg/docker/runtimes/binary/build.Dockerfile index 9d56a5e..2f2bf49 100644 --- a/pkg/docker/runtimes/binary/build.Dockerfile +++ b/pkg/docker/runtimes/binary/build.Dockerfile @@ -1,5 +1,5 @@ -ARG GO_VERSION=1.22 -ARG ALPINE_VERSION=3.19 +ARG GO_VERSION=1.27.3 +ARG ALPINE_VERSION=3.24 FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder From 1831b9ca3bfd2b5cc420964f6e4ae9c2fb3b4ec1 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 28 Oct 2026 13:41:53 +0000 Subject: [PATCH 04/14] Update README --- README.md | 194 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 131 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index d90e651..ff754d2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # tinyFaaS: A Lightweight FaaS Platform for Edge Environments -tinyFaaS is a lightweight FaaS (Function-as-a-Service) platform for edge environment with a focus on performance in constrained environments. +tinyFaaS is a lightweight FaaS (Function-as-a-Service) platform for edge +environment with a focus on performance in constrained environments. ## Research @@ -9,7 +10,10 @@ If you use this software in a publication, please cite it as: ### Text -T. Pfandzelter and D. Bermbach, **tinyFaaS: A Lightweight FaaS Platform for Edge Environments**, Proceedings of the 2020 IEEE International Conference on Fog Computing (ICFC '20), Sydney, Australia, 2020, pp. 17-24, DOI: 10.1109/ICFC49376.2020.00011. +T. Pfandzelter and D. Bermbach, **tinyFaaS: A Lightweight FaaS Platform for Edge +Environments**, Proceedings of the 2020 IEEE International Conference on Fog +Computing (ICFC '20), Sydney, Australia, 2020, pp. 17-24, DOI: +10.1109/ICFC49376.2020.00011. ### BibTeX @@ -25,24 +29,29 @@ T. Pfandzelter and D. Bermbach, **tinyFaaS: A Lightweight FaaS Platform for Edge } ``` -For a full list of publications, please see [our website](https://www.tu.berlin/en/mcc/research/publications). +For a full list of publications, please see [our +website](https://www.tu.berlin/en/3s/research/publications). ### License -The code in this repository is licensed under the terms of the [MIT](./LICENSE) license. +The code in this repository is licensed under the terms of the [MIT](./LICENSE) +license. ## Instructions -**Disclaimer**: Please note that this will use your computer's Docker instance to manage containers and will allow anyone in your network to start Docker containers with arbitrary code. -If you don't know what this means you do _not_ want to run this on your computer. -Additionally, note that this software is provided as a research prototype and is not production-ready. +> [!CAUTION] +> tinyFaaS uses the local Docker instance to manage containers, and it allows +> anyone on your network to start Docker containers running arbitrary code. If +> you don't understand what this means, you should not run this software on your +> computer. Also note that this is a research prototype and is not +> production-ready. ### About -tinyFaaS comprises the _management service_, the _reverse proxy_, and a number of _function handlers_. -In order to run tinyFaaS, the management service has to be deployed. -It will then automatically start the reverse proxy. -Once a function is deployed to tinyFaaS, function handlers are created automatically. +tinyFaaS comprises the _management service_, the _reverse proxy_, and a number +of _function handlers_. In order to run tinyFaaS, the management service has to +be deployed. It will then automatically start the reverse proxy. Once a function +is deployed to tinyFaaS, function handlers are created automatically. ### Prerequisites @@ -53,9 +62,12 @@ Before you get started, make sure you have the following dependencies installed: - Make - a writable directory (tinyFaaS writes temporary files to a `./tmp` directory) -Note that tinyFaaS is intended for Linux hosts (`x86_64` and `arm64`). -Due to limitations of Docker Desktop for Mac, installing and running [`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect) is necessary to run tinyFaaS on macOS hosts. -Running tinyFaaS on Windows computers (native or through WSL) is probably possible but has not been tested and is thus not recommended. +Note that tinyFaaS is intended for Linux hosts (`x86_64` and `arm64`). Due to +limitations of Docker Desktop for Mac, installing and running +[`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect) is +necessary to run tinyFaaS on macOS hosts. Running tinyFaaS on Windows computers +(native or through WSL) is probably possible but has not been tested and is thus +not recommended. ### Getting Started @@ -70,78 +82,124 @@ Please note that you cannot use tinyFaaS until the reverse proxy is running. ### Managing Functions -To manage functions on tinyFaaS, use the included scripts included in `./src/scripts`. - -To upload a function, run `upload.sh {FOLDER} {NAME} {ENV} {THREADS}`, where `{FOLDER}` is the path to your function code, `{NAME}` is the name for your function, `{ENV}` is the environment you would like to use (`python3`, `nodejs`, or `binary`), and `{THREADS}` is a number specifying the number of function handlers for your function. -For example, you might call `./scripts/upload.sh "./test/fns/sieve-of-eratosthenes" "sieve" "nodejs" 1` to upload the _sieve of Eratosthenes_ example function included in this repository. -This requires the `zip`, `base64`, and `curl` utilities. - -Alternatively, you can also upload functions from a zipped file available at some URL. -Use the included script as a starting point: `uploadURL.sh {URL} {NAME} {ENV} {THREADS} {SUBFOLDER_PATH}`, where `{URL}` is the URL to a zip that has your function code, `{SUBFOLDER_PATH}` is the folder of the code within that zip (use `/` if the code is in the top-level), `{NAME}` is the name for your function, `{ENV}` is the environment, and `{THREADS}` is a number specifying the number of function handlers for your function. -For example, you might call `uploadURL.sh "https://github.com/OpenFogStack/tinyFaas/archive/main.zip" "tinyFaaS-main/test/fns/sieve-of-eratosthenes" "sieve" "nodejs" 1` to upload the _sieve of Eratosthenes_ example function included in this repository. +To manage functions on tinyFaaS, use the scripts included in `./scripts`. + +To upload a function, run `upload.sh {FOLDER} {NAME} {ENV} {THREADS}`, where +`{FOLDER}` is the path to your function code, `{NAME}` is the name for your +function, `{ENV}` is the environment you want to use (`python3`, `nodejs`, or +`binary`), and `{THREADS}` is the number of function handlers for your function. +For example, you can run `./scripts/upload.sh "./test/fns/sieve-of-eratosthenes" +"sieve" "nodejs" 1` to upload the _Sieve of Eratosthenes_ example function +included in this repository. This requires the `zip`, `base64`, and `curl` +utilities. + +Alternatively, you can upload a function from a zip file available at a URL. Use +the included script as a starting point: `uploadURL.sh {URL} {NAME} {ENV} +{THREADS} {SUBFOLDER_PATH}`, where `{URL}` is the URL of a zip file containing +your function code, `{NAME}` is the name for your function, `{ENV}` is the +environment, `{THREADS}` is the number of function handlers, and +`{SUBFOLDER_PATH}` is the folder containing the code within the zip (use `/` if +the code is at the top level). For example, you can run `uploadURL.sh +"https://github.com/OpenFogStack/tinyFaaS/archive/main.zip" +"tinyFaaS-main/test/fns/sieve-of-eratosthenes" "sieve" "nodejs" 1` to upload the +_Sieve of Eratosthenes_ example function included in this repository. To get a list of existing functions, run `list.sh`. -To delete a function, run `delete.sh {NAME}`, where `{NAME}` is the name of the function you want to remove. +To delete a function, run `delete.sh {NAME}`, where `{NAME}` is the name of the +function you want to remove. -Additionally, we provide scripts to read logs from your function and to wipe all functions from tinyFaaS. +We also provide scripts to read logs from your functions and to wipe all +functions from tinyFaaS. ### Writing Functions -This tinyFaaS prototype only supports functions written for NodeJS 20, Python 3.9, and binary functions. -A good place to get started with writing functions is the selection of test functions in [`./test/fns`](./test/fns/). -HTTP headers and GRPC Metadata are accessible in NodeJS and Python functions as key values. Check the "show-headers" test functions for more information. +This tinyFaaS prototype supports functions written for Go 1.27, Node.js 26, +Python 3.13, and binary functions. A good place to start is the collection of +test functions in [`./test/fns`](./test/fns/). In Node.js and Python functions, +HTTP headers and gRPC metadata are available as key-value pairs. See the +"show-headers" test functions for more information. + +#### Go -#### NodeJS 20 +Your function must be supplied as a file named `fn.go` that exposes the package +`main` with the function `fn` that is invoked for every function invocation. +This method must accept two arguments: `data` of type `string`, and `headers` of +type `map[string]string`. Must return a string and an error as return values. +You may also provide a `go.mod` file from which dependencies will be installed +alongside your function. -Your function must be supplied as a Node module with the name `fn` that exports a single function that takes the `req` and `res` parameters for request and response, respectively. -`res` supports the `send()` function that has one parameter, a string that is passed to the client as-is. +#### Node.js -#### Python 3.9 +Your function must be supplied as a Node module with the name `fn` that exports +a single function that takes the `req` and `res` parameters for request and +response, respectively. `res` supports the `send()` function that has one +parameter, a string that is passed to the client as-is. -Your function must be supplied as a file named `fn.py` that exposes a method `fn` that is invoked for every function invocation. -This method must accept a string as an input (that can also be `None`) and must provide a string as a return value. -You may also provide a `requirements.txt` file from which dependencies will be installed alongside your function. -Any other data you provide will be available. +#### Python + +Your function must be supplied as a file named `fn.py` that exposes a method +`fn` that is invoked for every function invocation. This method must accept a +string as an input (that can also be `None`) and must provide a string as a +return value. You may also provide a `requirements.txt` file from which +dependencies will be installed alongside your function. Any other data you +provide will be available. #### Binary -Your function must be provided as a `fn.sh` shell script that is invoked for every function call. -This shell script may also call other binaries as needed. -Input data is provided from `stdin`. -Output responses should be provided on `stdout`. +Your function must be provided as a `fn.sh` shell script that is invoked for +every function call. This shell script may also call other binaries as needed. +Input data is provided from `stdin`. Output responses should be provided on +`stdout`. ### Calling Functions tinyFaaS supports different application layer protocols at its reverse proxy. -Different protocols are useful for different use-cases: CoAP for lightweight communication, e.g., for IoT devices; HTTP to support traditional web applications; GRPC for inter-process communication. +Different protocols are useful for different use-cases: CoAP for lightweight +communication, e.g., for IoT devices; HTTP to support traditional web +applications; GRPC for inter-process communication. #### CoAP -To call a tinyFaaS function using its CoAP endpoint, make a GET or POST request to `coap://{HOST}:{PORT}/{NAME}` where `{HOST}` is the address of the tinyFaaS host, `{PORT}` is the port for the tinyFaaS CoAP endpoint (default is `5683`), and `{NAME}` is the name of your function. -You may include data in any form you want, it will be passed to your function. +To call a tinyFaaS function using its CoAP endpoint, make a GET or POST request +to `coap://{HOST}:{PORT}/{NAME}` where `{HOST}` is the address of the tinyFaaS +host, `{PORT}` is the port for the tinyFaaS CoAP endpoint (default is `5683`), +and `{NAME}` is the name of your function. You may include data in any form you +want, it will be passed to your function. -Unfortunately, [`curl` does not yet support CoAP](https://curl.se/mail/lib-2018-05/0017.html), but [a number](https://github.com/coapjs/coap-cli) [of other](https://aiocoap.readthedocs.io/en/latest/tools.html) [tools are available](https://fitbit.github.io/golden-gate/tools/coap_client.html). +Unfortunately, [`curl` does not yet support +CoAP](https://curl.se/mail/lib-2018-05/0017.html), but [a +number](https://github.com/coapjs/coap-cli) [of +other](https://aiocoap.readthedocs.io/en/latest/tools.html) [tools are +available](https://fitbit.github.io/golden-gate/tools/coap_client.html). #### HTTP -To call a tinyFaaS function using its HTTP endpoint, make a GET or POST request to `http://{HOST}:{PORT}/{NAME}` where `{HOST}` is the address of the tinyFaaS host, `{PORT}` is the port for the tinyFaaS HTTP endpoint (default is `80`), and `{NAME}` is the name of your function. -You may include data in any form you want, it will be passed to your function. +To call a tinyFaaS function using its HTTP endpoint, make a GET or POST request +to `http://{HOST}:{PORT}/{NAME}` where `{HOST}` is the address of the tinyFaaS +host, `{PORT}` is the port for the tinyFaaS HTTP endpoint (default is `80`), and +`{NAME}` is the name of your function. You may include data in any form you +want, it will be passed to your function. TLS is not supported (but contributions are welcome). -To make an asynchronous request, pass the `X-tinyFaaS-Async` header with any value. -An asynchronous request means the client will receive a `202` response code immediately and no function results will be sent back. +To make an asynchronous request, pass the `X-tinyFaaS-Async` header with any +value. An asynchronous request means the client will receive a `202` response +code immediately and no function results will be sent back. -```sh +```bash curl --header "X-tinyFaaS-Async: true" "http://localhost:8000/sieve" ``` #### gRPC -To use the gRPC endpoint, compile the `tinyfaas` protocol buffer (included in [`./pkg/grpc/tinyfaas`](./pkg/grpc/tinyfaas)) for your programming language and import it into your application. -We already provide compiled versions for Go and Python in that directory. -Specify the tinyFaaS host and port (default is `9000`) for the GRPC endpoint and use the `Request` function with the `functionIdentifier` being your function's name and the `data` field including data in any form you want. +To use the gRPC endpoint, compile the `tinyfaas` protocol buffer (included in +[`./pkg/grpc/tinyfaas`](./pkg/grpc/tinyfaas)) for your programming language and +import it into your application. We already provide compiled versions for Go and +Python in that directory. Specify the tinyFaaS host and port (default is `9000`) +for the GRPC endpoint and use the `Request` function with the +`functionIdentifier` being your function's name and the `data` field including +data in any form you want. ### Removing tinyFaaS @@ -172,21 +230,27 @@ By default, tinyFaaS will use the following ports: | 8000 | TCP | HTTP Endpoint | | 9000 | TCP | GRPC Endpoint | -To change the port of the management service, change the port binding in the `docker run` command. +To change the port of the management service, change the port binding in the +`docker run` command. -To change or deactivate the endpoints of tinyFaaS, you can use the `COAP_PORT`, `HTTP_PORT`, and `GRPC_PORT` environment variables, which must be passed to the management service Docker container. -Specify `-1` to deactivate a specific endpoint. -For example, to use `6000` as the port for the CoAP and deactivate GRPC, run the management service with this command: +To change or deactivate the endpoints of tinyFaaS, you can use the `COAP_PORT`, +`HTTP_PORT`, and `GRPC_PORT` environment variables, which must be passed to the +management service Docker container. Specify `-1` to deactivate a specific +endpoint. For example, to use `6000` as the port for the CoAP and deactivate +GRPC, run the management service with this command: ```bash -docker run --env COAP_PORT=6000 --env GRPC_PORT=-1 -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 --name tinyfaas-mgmt -d tinyfaas-mgmt tinyfaas-mgmt +docker run --env COAP_PORT=6000 --env GRPC_PORT=-1 \ + -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 \ + --name tinyfaas-mgmt -d tinyfaas-mgmt tinyfaas-mgmt ``` ### Tests -The tests in [`./test`](./test) test the end-to-end functionality of tinyFaaS and are expected to complete successfully. -We use these tests during development to ensure no patches break any functionality. -The tests can also serve as documentation on the expected behavior of tinyFaaS. +The tests in [`./test`](./test) test the end-to-end functionality of tinyFaaS +and are expected to complete successfully. We use these tests during development +to ensure no patches break any functionality. The tests can also serve as +documentation on the expected behavior of tinyFaaS. Running the tests requires: @@ -217,9 +281,13 @@ OK Tests will output a `.` (dot) for successful tests and `E` or `F` for failed tests. tinyFaaS output will be written to `tf_test.out`. -On macOS, [`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect) is necessary to run tinyFaaS. -There is a [known issue in `docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect/issues/36) that silently breaks the tunnel when Docker Desktop enters its resource saver mode. -If you find that tinyFaaS does not start properly on your macOS host, try restarting the tunnel: +On macOS, +[`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect) is +necessary to run tinyFaaS. There is a [known issue in +`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect/issues/36) +that silently breaks the tunnel when Docker Desktop enters its resource saver +mode. If you find that tinyFaaS does not start properly on your macOS host, try +restarting the tunnel: ```sh sudo brew services restart docker-mac-net-connect From cb749544b4044c38d6316663d559408418be46ec Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 28 Oct 2026 14:21:01 +0000 Subject: [PATCH 05/14] Replace Docker module with Moby module Because the Go module github.com/docker/docker is deprecated. See more info here: https://github.com/moby/moby/discussions/52404 --- go.mod | 62 ++++++------ go.sum | 207 ++++++++++++++++----------------------- pkg/docker/handler.go | 70 ++++++------- test/fns/hello-go/go.mod | 2 +- 4 files changed, 151 insertions(+), 190 deletions(-) diff --git a/go.mod b/go.mod index 3cb57cb..dd03f0c 100644 --- a/go.mod +++ b/go.mod @@ -1,46 +1,46 @@ module github.com/OpenFogStack/tinyFaaS -go 1.22 +go 1.27.3 require ( - github.com/docker/docker v27.0.0+incompatible github.com/google/uuid v1.6.0 + github.com/moby/go-archive v0.3.3 + github.com/moby/moby/api v1.56.1 + github.com/moby/moby/client v0.6.2 github.com/pfandzelter/go-coap v0.1.0 - google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.34.2 + google.golang.org/grpc v1.85.0 + google.golang.org/protobuf v1.36.12 ) require ( - github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/containerd/containerd v1.7.18 // indirect - github.com/containerd/log v0.1.0 // indirect + github.com/Microsoft/go-winio v0.6.4 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect + github.com/containerd/log v0.2.0 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-connections v0.8.2 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/go-logr/logr v1.4.2 // indirect + github.com/felixge/httpsnoop v1.1.0 // indirect + github.com/go-logr/logr v1.4.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.20.3 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect - github.com/moby/patternmatcher v0.6.0 // indirect - github.com/moby/sys/sequential v0.5.0 // indirect - github.com/moby/sys/user v0.1.0 // indirect - github.com/moby/term v0.5.0 // indirect - github.com/morikuni/aec v1.0.0 // indirect + github.com/moby/patternmatcher v0.6.1 // indirect + github.com/moby/sys/sequential v0.7.0 // indirect + github.com/moby/sys/user v0.5.0 // indirect + github.com/moby/sys/userns v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect - go.opentelemetry.io/otel v1.27.0 // indirect - go.opentelemetry.io/otel/metric v1.27.0 // indirect - go.opentelemetry.io/otel/trace v1.27.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.5.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect - gotest.tools/v3 v3.5.1 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/sirupsen/logrus v1.10.2 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect + golang.org/x/net v0.62.0 // indirect + golang.org/x/sys v0.49.0 // indirect + golang.org/x/text v0.43.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261026165753-2ffab32bce7e // indirect ) diff --git a/go.sum b/go.sum index 49752e7..2b21b4c 100644 --- a/go.sum +++ b/go.sum @@ -1,138 +1,99 @@ -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= -github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Microsoft/hcsshim v0.11.5 h1:haEcLNpj9Ka1gd3B3tAEs9CpE0c+1IhoL59w/exYU38= -github.com/Microsoft/hcsshim v0.11.5/go.mod h1:MV8xMfmECjl5HdO7U/3/hFVnkmSBjAjmA09d4bExKcU= -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/containerd/containerd v1.7.18 h1:jqjZTQNfXGoEaZdW1WwPU0RqSn1Bm2Ay/KJPUuO8nao= -github.com/containerd/containerd v1.7.18/go.mod h1:IYEk9/IO6wAPUz2bCMVUbsfXjzw5UNP5fLz4PsUygQ4= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/Microsoft/go-winio v0.6.4 h1:kJF2pamtYCWXf0xAT8sAkwKC0pMl2HYBrRPHAqyUc+g= +github.com/Microsoft/go-winio v0.6.4/go.mod h1:1xl5JXG4ze/m74GH6Dc4Mwxfc3VL5siRVQjIAlHH07U= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= +github.com/containerd/log v0.2.0 h1:BewD/umNgVnoczglOpX8eRMyEy5t5iPlu5AIpnWDONc= +github.com/containerd/log v0.2.0/go.mod h1:/M7L7CXKcPTfNC74XzaK+5H5KbO5+4lJVpuVI6vRLoM= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v27.0.0+incompatible h1:JRugTYuelmWlW0M3jakcIadDx2HUoUO6+Tf2C5jVfwA= -github.com/docker/docker v27.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-connections v0.8.2 h1:9d9DEokx5W7qlr0shkFXIxEA7+TTD+llwzcykSlxMNc= +github.com/docker/go-connections v0.8.2/go.mod h1:no1qkHdjq7kLMGUXYAduOhYPSJxxvgWBh7ogVvptn3Q= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= -github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc= +github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= +github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= +github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= -github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= -github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= -github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= -github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= -github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/moby/go-archive v0.3.3 h1:OxxR9paxsluYi+zDUEXTTaIxtkK3viymW+Ka7vRhhME= +github.com/moby/go-archive v0.3.3/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE= +github.com/moby/moby/api v1.56.1 h1:PpWkvVPB7Fr/No8w+TfyJ/I6rWZ2YPZhT3JorIg+06c= +github.com/moby/moby/api v1.56.1/go.mod h1:sZ+THbVWkjOmBPPfbnzdD/G1LuIexWhqlSHHPTDQ1Uk= +github.com/moby/moby/client v0.6.2 h1:ekSPlMccrZGcw6Scb8T9D39qE0mB+XupU/yS0zNw9N4= +github.com/moby/moby/client v0.6.2/go.mod h1:DGcnO7qmPJrqobx/ggQgQ/AUk+2wgVdQv7uxB0/mEsc= +github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x084U= +github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/mount v0.3.5 h1:eS3fsZTjHaBihwjp4/+5Z3jxqLXYsbwxqpVSfFv3M00= +github.com/moby/sys/mount v0.3.5/go.mod h1:WUQDO+/uCiCIkIztx8SrwIDVn2dtMFRBebRhpDFT71M= +github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= +github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= +github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8= +github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o= +github.com/moby/sys/user v0.5.0 h1:5+S4lyoavGyX1DGs68NW8xpx48T9+a7ogSUc0KjZg8Y= +github.com/moby/sys/user v0.5.0/go.mod h1:4mQzP5aTmaLjDLp/dc870oNkik6E9vjRtWYwI05gvow= +github.com/moby/sys/userns v0.2.1 h1:4OvdM7BcPkASbuouHsbW3aeMJSFlYDldBRnXVZhaRk8= +github.com/moby/sys/userns v0.2.1/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pfandzelter/go-coap v0.1.0 h1:R6RqR3aTxJlnmuFDagiCJqXhN+WuwUoUS4+OY/pPnYY= github.com/pfandzelter/go-coap v0.1.0/go.mod h1:pNQG3knnPGxs+aCrGUdTDHqy1HqE9175DnhAomuVFM0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 h1:9l89oX4ba9kHbBol3Xin3leYJ+252h0zszDtBwyKe2A= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0/go.mod h1:XLZfZboOJWHNKUv7eH0inh0E9VV6eWDFB/9yJyTLPp0= -go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= -go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= -go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= -go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= -go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o= -go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= -go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= -go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= -go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= -go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 h1:Di6ANFilr+S60a4S61ZM00vLdw0IrQOSMS2/6mrnOU0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= -gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= +github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo= +github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= +go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I= +go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0= +go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw= +go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= +golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= +golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= +gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= +gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261026165753-2ffab32bce7e h1:w3fy/G8OrJHYexn+u5y7hFyc8YRRIr7DCevtIOwAcGY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261026165753-2ffab32bce7e/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= +google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= +gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= +pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= +pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= diff --git a/pkg/docker/handler.go b/pkg/docker/handler.go index 0b4c9f8..e485b41 100644 --- a/pkg/docker/handler.go +++ b/pkg/docker/handler.go @@ -13,14 +13,11 @@ import ( "sync" "time" - "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" - "github.com/docker/docker/api/types/image" - "github.com/docker/docker/api/types/network" - "github.com/docker/docker/client" - "github.com/docker/docker/pkg/archive" - "github.com/docker/docker/pkg/stdcopy" "github.com/google/uuid" + "github.com/moby/go-archive" + "github.com/moby/moby/api/pkg/stdcopy" + "github.com/moby/moby/api/types/container" + "github.com/moby/moby/client" "github.com/OpenFogStack/tinyFaaS/pkg/manager" "github.com/OpenFogStack/tinyFaaS/pkg/util" @@ -128,7 +125,7 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st r, err := db.client.ImageBuild( context.Background(), tar, - types.ImageBuildOptions{ + client.ImageBuildOptions{ Tags: []string{dh.uniqueName}, Remove: true, Dockerfile: "Dockerfile", @@ -155,7 +152,7 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st network, err := db.client.NetworkCreate( context.Background(), dh.uniqueName, - network.CreateOptions{ + client.NetworkCreateOptions{ Labels: map[string]string{ "tinyfaas-function": dh.name, "tinyFaaS": db.tinyFaaSID, @@ -179,31 +176,31 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st // create containers // docker run -d --network --name for i := 0; i < dh.threads; i++ { - container, err := db.client.ContainerCreate( + c, err := db.client.ContainerCreate( context.Background(), - &container.Config{ - Image: dh.uniqueName, - Labels: map[string]string{ - "tinyfaas-function": dh.name, - "tinyFaaS": db.tinyFaaSID, + client.ContainerCreateOptions{ + Config: &container.Config{ + Image: dh.uniqueName, + Labels: map[string]string{ + "tinyfaas-function": dh.name, + "tinyFaaS": db.tinyFaaSID, + }, + Env: e, }, - Env: e, - }, - &container.HostConfig{ - NetworkMode: container.NetworkMode(dh.uniqueName), + HostConfig: &container.HostConfig{ + NetworkMode: container.NetworkMode(dh.uniqueName), + }, + Name: dh.uniqueName + fmt.Sprintf("-%d", i), }, - nil, - nil, - dh.uniqueName+fmt.Sprintf("-%d", i), ) if err != nil { return nil, err } - log.Println("created container", container.ID) + log.Println("created container", c.ID) - dh.containers = append(dh.containers, container.ID) + dh.containers = append(dh.containers, c.ID) } // remove folder @@ -233,10 +230,10 @@ func (dh *dockerHandler) Start() error { for _, c := range dh.containers { wg.Add(1) go func(c string) { - err := dh.client.ContainerStart( + _, err := dh.client.ContainerStart( context.Background(), c, - container.StartOptions{}, + client.ContainerStartOptions{}, ) wg.Done() if err != nil { @@ -255,14 +252,16 @@ func (dh *dockerHandler) Start() error { c, err := dh.client.ContainerInspect( context.Background(), container, + client.ContainerInspectOptions{}, ) if err != nil { return err } - dh.handlerIPs = append(dh.handlerIPs, c.NetworkSettings.Networks[dh.uniqueName].IPAddress) + ip := c.Container.NetworkSettings.Networks[dh.uniqueName].IPAddress.String() + dh.handlerIPs = append(dh.handlerIPs, ip) - log.Println("got ip", c.NetworkSettings.Networks[dh.uniqueName].IPAddress, "for container", container) + log.Println("got ip", ip, "for container", container) } // wait for the containers to be ready @@ -330,10 +329,10 @@ func (dh *dockerHandler) Destroy() error { timeout := 1 // seconds - err := dh.client.ContainerStop( + _, err := dh.client.ContainerStop( context.Background(), c, - container.StopOptions{ + client.ContainerStopOptions{ Timeout: &timeout, }, ) @@ -343,10 +342,10 @@ func (dh *dockerHandler) Destroy() error { log.Println("stopped container", c) - err = dh.client.ContainerRemove( + _, err = dh.client.ContainerRemove( context.Background(), c, - container.RemoveOptions{}, + client.ContainerRemoveOptions{}, ) wg.Done() if err != nil { @@ -360,9 +359,10 @@ func (dh *dockerHandler) Destroy() error { // remove network // docker network rm - err := dh.client.NetworkRemove( + _, err := dh.client.NetworkRemove( context.Background(), dh.network, + client.NetworkRemoveOptions{}, ) if err != nil { return err @@ -375,7 +375,7 @@ func (dh *dockerHandler) Destroy() error { _, err = dh.client.ImageRemove( context.Background(), dh.uniqueName, - image.RemoveOptions{}, + client.ImageRemoveOptions{}, ) if err != nil { @@ -393,7 +393,7 @@ func (dh *dockerHandler) getContainerLogs(c string) (string, error) { l, err := dh.client.ContainerLogs( context.Background(), c, - container.LogsOptions{ + client.ContainerLogsOptions{ ShowStdout: true, ShowStderr: true, Timestamps: true, diff --git a/test/fns/hello-go/go.mod b/test/fns/hello-go/go.mod index 96990ec..6ec1907 100644 --- a/test/fns/hello-go/go.mod +++ b/test/fns/hello-go/go.mod @@ -1,3 +1,3 @@ module main -go 1.22 \ No newline at end of file +go 1.27.3 From 92395c9ceff62b5c275bf769a3960a6e27900b38 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 10:34:30 +0000 Subject: [PATCH 06/14] Format Python files with ruff --- test/fns/echo/fn.py | 5 ++++- test/fns/show-headers/fn.py | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/fns/echo/fn.py b/test/fns/echo/fn.py index 7b8231a..434da6f 100644 --- a/test/fns/echo/fn.py +++ b/test/fns/echo/fn.py @@ -2,6 +2,9 @@ import typing -def fn(input: typing.Optional[str], headers: typing.Optional[typing.Dict[str, str]]) -> typing.Optional[str]: + +def fn( + input: typing.Optional[str], headers: typing.Optional[typing.Dict[str, str]] +) -> typing.Optional[str]: """echo the input""" return input diff --git a/test/fns/show-headers/fn.py b/test/fns/show-headers/fn.py index 775f3d2..888320a 100644 --- a/test/fns/show-headers/fn.py +++ b/test/fns/show-headers/fn.py @@ -1,9 +1,12 @@ import json import typing -def fn(input: typing.Optional[str], headers: typing.Optional[typing.Dict[str, str]]) -> typing.Optional[str]: + +def fn( + input: typing.Optional[str], headers: typing.Optional[typing.Dict[str, str]] +) -> typing.Optional[str]: """echo the input""" if headers is not None: return json.dumps(headers) else: - return "{}" \ No newline at end of file + return "{}" From 5c8de9d9ec712723a9f6cf2d69ffa5e0b76502b9 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 10:57:53 +0000 Subject: [PATCH 07/14] Update README --- README.md | 179 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 118 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index ff754d2..d26238d 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,12 @@ is deployed to tinyFaaS, function handlers are created automatically. Before you get started, make sure you have the following dependencies installed: -- Go (>=v1.22) to compile management service and reverse proxy -- Docker (>=v24) -- Make -- a writable directory (tinyFaaS writes temporary files to a `./tmp` directory) +- Go, to compile management service and reverse proxy, +- Docker (>=v29), +- Make, +- a writable directory (tinyFaaS writes temporary files to a `./tmp` directory). + +You can see the exact required Go version in the [go.mod](./go.mod) file. Note that tinyFaaS is intended for Linux hosts (`x86_64` and `arm64`). Due to limitations of Docker Desktop for Mac, installing and running @@ -77,48 +79,71 @@ Start tinyFaaS with: make start ``` -The reverse proxy will be started automatically. -Please note that you cannot use tinyFaaS until the reverse proxy is running. +This builds tinyFaaS for your host platform if necessary and runs it with +`sudo`, so you may be asked for your password. + +The reverse proxy will be started automatically. Please note that you cannot use +tinyFaaS until the reverse proxy is running. ### Managing Functions To manage functions on tinyFaaS, use the scripts included in `./scripts`. -To upload a function, run `upload.sh {FOLDER} {NAME} {ENV} {THREADS}`, where -`{FOLDER}` is the path to your function code, `{NAME}` is the name for your -function, `{ENV}` is the environment you want to use (`python3`, `nodejs`, or -`binary`), and `{THREADS}` is the number of function handlers for your function. -For example, you can run `./scripts/upload.sh "./test/fns/sieve-of-eratosthenes" -"sieve" "nodejs" 1` to upload the _Sieve of Eratosthenes_ example function -included in this repository. This requires the `zip`, `base64`, and `curl` +#### Deploy a function + +There are two ways to deploy a function: + +```sh +$ ./scripts/upload.sh {FOLDER} {NAME} {ENV} {THREADS} +$ ./scripts/uploadURL.sh {URL} {SUBFOLDER_PATH} {NAME} {ENV} {THREADS} +``` + +The main difference is that `upload.sh` takes a local folder that contains your +function code, whereas `uploadURL.sh` deploys a function from a zip file that +the tinyFaaS manager can reach at the given URL. In that case, you also need to +give the folder that contains the code inside the zip file (use `/` if the code +is at the top level). `upload.sh` requires the `zip`, `base64`, and `curl` utilities. -Alternatively, you can upload a function from a zip file available at a URL. Use -the included script as a starting point: `uploadURL.sh {URL} {NAME} {ENV} -{THREADS} {SUBFOLDER_PATH}`, where `{URL}` is the URL of a zip file containing -your function code, `{NAME}` is the name for your function, `{ENV}` is the -environment, `{THREADS}` is the number of function handlers, and -`{SUBFOLDER_PATH}` is the folder containing the code within the zip (use `/` if -the code is at the top level). For example, you can run `uploadURL.sh -"https://github.com/OpenFogStack/tinyFaaS/archive/main.zip" -"tinyFaaS-main/test/fns/sieve-of-eratosthenes" "sieve" "nodejs" 1` to upload the -_Sieve of Eratosthenes_ example function included in this repository. +The other available options are: -To get a list of existing functions, run `list.sh`. +* `{NAME}`: the name of the function, which also identifies it. You need this + name to call the function. +* `{ENV}`: the runtime you want to use (`python3`, `go`, `nodejs`, `binary`). +* `{THREADS}`: the number of function handlers, which is how many identical + containers are created for the function. Each container can already handle + requests in parallel on its own, and the reverse proxy forwards a call to a + random function handler. If you want to change this value, you need to + re-deploy the function. -To delete a function, run `delete.sh {NAME}`, where `{NAME}` is the name of the -function you want to remove. +Examples: -We also provide scripts to read logs from your functions and to wipe all -functions from tinyFaaS. +```sh +$ ./scripts/upload.sh "./test/fns/sieve-of-eratosthenes" "sieve" "nodejs" 1 +$ ./scripts/uploadURL.sh \ + "https://github.com/OpenFogStack/tinyFaaS/archive/main.zip" \ + "tinyFaaS-main/test/fns/sieve-of-eratosthenes" \ + "sieve" "nodejs" 1 +``` + +#### Other commands + +To get a list of existing functions, run `./scripts/list.sh`. + +To delete a function, run `./scripts/delete.sh {NAME}`. To remove all +functions, run `./scripts/wipe-functions.sh`. + +To read the logs of all functions, run `./scripts/logs.sh`. The script does not +take any arguments. To read the logs of a single function, call the management +service directly with `curl "localhost:8080/logs?name={NAME}"`. ### Writing Functions This tinyFaaS prototype supports functions written for Go 1.27, Node.js 26, Python 3.13, and binary functions. A good place to start is the collection of -test functions in [`./test/fns`](./test/fns/). In Node.js and Python functions, -HTTP headers and gRPC metadata are available as key-value pairs. See the -"show-headers" test functions for more information. +test functions in [`./test/fns`](./test/fns/). In Go, Node.js and Python +functions, HTTP headers and gRPC metadata are available as key-value pairs. See +the "show-headers" test functions for more information. #### Go @@ -139,18 +164,18 @@ parameter, a string that is passed to the client as-is. #### Python Your function must be supplied as a file named `fn.py` that exposes a method -`fn` that is invoked for every function invocation. This method must accept a -string as an input (that can also be `None`) and must provide a string as a -return value. You may also provide a `requirements.txt` file from which -dependencies will be installed alongside your function. Any other data you -provide will be available. +`fn` that is invoked for every function invocation. This method must accept two +arguments: the input as a string (that can also be `None`) and the headers as a +dictionary. It must return a string or `None`. You may also provide a +`requirements.txt` file from which dependencies will be installed alongside your +function. Any other data you provide will be available. #### Binary Your function must be provided as a `fn.sh` shell script that is invoked for every function call. This shell script may also call other binaries as needed. Input data is provided from `stdin`. Output responses should be provided on -`stdout`. +`stdout`. Anything written to `stderr` is also included in the response. ### Calling Functions @@ -177,8 +202,8 @@ available](https://fitbit.github.io/golden-gate/tools/coap_client.html). To call a tinyFaaS function using its HTTP endpoint, make a GET or POST request to `http://{HOST}:{PORT}/{NAME}` where `{HOST}` is the address of the tinyFaaS -host, `{PORT}` is the port for the tinyFaaS HTTP endpoint (default is `80`), and -`{NAME}` is the name of your function. You may include data in any form you +host, `{PORT}` is the port for the tinyFaaS HTTP endpoint (default is `8000`), +and `{NAME}` is the name of your function. You may include data in any form you want, it will be passed to your function. TLS is not supported (but contributions are welcome). @@ -203,19 +228,19 @@ data in any form you want. ### Removing tinyFaaS -When you stop the management service with `SIGINT` (`Ctrl+C`), the reverse proxy and all function handlers should be stopped. -You can also use: +When you stop the management service with `SIGINT` (`Ctrl+C`), the reverse proxy +and all function handlers should be stopped. You can also use: -```bash +```sh make clean ``` OR -```bash -docker rm -f $$(docker ps -a -q --filter label=tinyFaaS) -docker network rm $$(docker network ls -q --filter label=tinyFaaS) -docker rmi $$(docker image ls -q --filter label=tinyFaaS) +```sh +docker rm -f $(docker ps -a -q --filter label=tinyFaaS) +docker network rm $(docker network ls -q --filter label=tinyFaaS) +docker rmi $(docker image ls -q --filter label=tinyFaaS) rm -rf ./tmp ``` @@ -230,19 +255,19 @@ By default, tinyFaaS will use the following ports: | 8000 | TCP | HTTP Endpoint | | 9000 | TCP | GRPC Endpoint | -To change the port of the management service, change the port binding in the -`docker run` command. +The scripts in `./scripts` expect the management service on port `8080`. -To change or deactivate the endpoints of tinyFaaS, you can use the `COAP_PORT`, -`HTTP_PORT`, and `GRPC_PORT` environment variables, which must be passed to the -management service Docker container. Specify `-1` to deactivate a specific -endpoint. For example, to use `6000` as the port for the CoAP and deactivate -GRPC, run the management service with this command: +To change or deactivate the endpoints of tinyFaaS, you can use the `coap_PORT`, +`http_PORT`, and `grpc_PORT` environment variables (the names are +case-sensitive), which must be passed to the management service. Specify `-1` to +deactivate a specific endpoint. `sudo` does not pass your environment variables +on by default, so set them in the command that runs the binary rather than +using `make start`. For example, to use `6000` as the port for CoAP and +deactivate GRPC, run: -```bash -docker run --env COAP_PORT=6000 --env GRPC_PORT=-1 \ - -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 \ - --name tinyfaas-mgmt -d tinyfaas-mgmt tinyfaas-mgmt +```sh +make build +sudo env coap_PORT=6000 grpc_PORT=-1 ./tinyfaas-$(go env GOOS)-$(go env GOARCH) ``` ### Tests @@ -257,7 +282,8 @@ Running the tests requires: - Python >3.10 with the `venv` module - a tinyFaaS binary built for your host -Create a virtual environment for Python and install the necessary dependencies for CoAP and gRPC: +Create a virtual environment for Python and install the necessary dependencies +for CoAP and gRPC: ```sh python3 -m venv .venv @@ -265,7 +291,8 @@ source .venv/bin/activate python3 -m pip install -r test/requirements.txt ``` -If you do not install these requirements, test runs are limited to invocations with HTTP. +If you do not install these requirements, test runs are limited to invocations +with HTTP. Run the tests with: @@ -278,8 +305,8 @@ Ran 13 tests in 28.063s OK ``` -Tests will output a `.` (dot) for successful tests and `E` or `F` for failed tests. -tinyFaaS output will be written to `tf_test.out`. +Tests will output a `.` (dot) for successful tests and `E` or `F` for failed +tests. tinyFaaS output will be written to `tf_test.out`. On macOS, [`docker-mac-net-connect`](https://github.com/chipmk/docker-mac-net-connect) is @@ -292,3 +319,33 @@ restarting the tunnel: ```sh sudo brew services restart docker-mac-net-connect ``` + +### Known limitations + +#### HTTP status code and headers + +Any function, in any runtime, cannot control the HTTP status code or the HTTP +headers that are returned. Only the body is sent back to the client. If the +function returns an error or throws an exception, the HTTP status is still 200 +and the body contains the error instead of the function's result. In the binary +runtime, the body contains only the exit error (for example, `exit status 1`), +not the output of the script. + +To recap, for function requests, tinyFaaS returns the following HTTP status +codes to the client: + +* `200 OK`: The container responded with any status: success, a Python + exception, a Go error, a non-zero exit from a binary, or a Node.js + `res.status(...)`. +* `202 Accepted`: The request had the `X-tinyFaaS-Async` header. The proxy + replies straight away and never waits for the function. +* `404 Not Found`: No function is deployed under that name. +* `500 Internal Server Error`: The proxy couldn't read the client's request + body, couldn't reach the container (connection refused, or the container + crashed mid-request), or couldn't read the container's response. + +#### Function timeout + +The reverse proxy does not set a timeout for a function request. A synchronous +function that hangs keeps the client waiting forever instead of getting an error +code. From 280dd573d693d86b6162cb79f2012c4b58306b9e Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 29 Oct 2026 11:54:08 +0000 Subject: [PATCH 08/14] Update LICENSE with latest contributors --- LICENSE | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 549f565..8653757 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,21 @@ Copyright (c) 2020 Tobias Pfandzelter, Emily Dietrich -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Copyright (c) 2023 Natalie Carl +Copyright (c) 2024 Mohammadreza Malekabbasi +Copyright (c) 2026 Emanuele Petriglia -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 71f6470e3d21b9644afca40a179006bb7467b874 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 11:06:47 +0000 Subject: [PATCH 09/14] Update Go code and Makefile --- Makefile | 18 ++-- README.md | 6 ++ cmd/manager/main.go | 28 ++--- cmd/rproxy/main.go | 6 -- go.mod | 6 ++ go.sum | 16 +++ pkg/coap/coap.go | 2 - pkg/docker/handler.go | 149 +++++++++++++++----------- pkg/grpc/grpc.go | 1 - pkg/grpc/tinyfaas/tinyfaas.pb.go | 115 +++++++------------- pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go | 43 ++++++-- pkg/http/http.go | 7 +- pkg/manager/manager.go | 37 +++---- pkg/rproxy/rproxy.go | 10 +- 14 files changed, 228 insertions(+), 216 deletions(-) diff --git a/Makefile b/Makefile index 8973c2b..2abc056 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ TEST_DIR := ./test SUPPORTED_ARCH=amd64 arm arm64 RUNTIMES := $(shell find pkg/docker/runtimes -name Dockerfile | xargs -n1 dirname | xargs -n1 basename) +# Some commands require root. +SUDO ?= $(if $(filter 0,$(shell id -u)),,sudo) + OS=$(shell go env GOOS) ARCH=$(shell go env GOARCH) @@ -17,7 +20,7 @@ build: tinyfaas-${OS}-${ARCH} .PHONY: start start: tinyfaas-${OS}-${ARCH} - ./$< + $(SUDO) ./$< .PHONY: test test: build ${TEST_DIR}/test_all.py pkg/grpc/tinyfaas/tinyfaas_pb2.py pkg/grpc/tinyfaas/tinyfaas_pb2.pyi pkg/grpc/tinyfaas/tinyfaas_pb2_grpc.py @@ -25,7 +28,10 @@ test: build ${TEST_DIR}/test_all.py pkg/grpc/tinyfaas/tinyfaas_pb2.py pkg/grpc/t .PHONY: clean clean: clean.sh - @sh clean.sh + @$(SUDO) sh clean.sh + +.PHONY: clean-generated +clean-generated: rm -rfv pkg/docker/runtimes-*/ rm -fv tinyfaas-*-* cmd/manager/rproxy-*.bin @@ -41,10 +47,10 @@ pkg/docker/runtimes-$(arch)/$(runtime): pkg/docker/runtimes-$(arch)/$(runtime)/D pkg/docker/runtimes-$(arch)/$(runtime)/blob.tar.gz: pkg/docker/runtimes/$(runtime)/build.Dockerfile mkdir -p $$(@D) - cd $$( $$@ - docker kill $${PROJECT_NAME}-$(runtime) + cd $$( $$@ + $$(SUDO) docker kill $${PROJECT_NAME}-$(runtime) pkg/docker/runtimes-$(arch)/$(runtime)/Dockerfile: pkg/docker/runtimes/$(runtime)/Dockerfile mkdir -p $$(@D) diff --git a/README.md b/README.md index d26238d..30f69bc 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,12 @@ docker rmi $(docker image ls -q --filter label=tinyFaaS) rm -rf ./tmp ``` +You can also remove the files generated to build tinyFaaS with: + +```sh +make clean-generated +``` + ### Specifying Ports By default, tinyFaaS will use the following ports: diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 75778e4..8b752a4 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -4,6 +4,7 @@ import ( "bufio" _ "embed" "encoding/json" + "errors" "fmt" "io" "log" @@ -31,7 +32,6 @@ type server struct { } func main() { - log.SetFlags(log.LstdFlags | log.Lshortfile) log.SetPrefix("manager: ") @@ -42,7 +42,7 @@ func main() { } for p := range ports { - portstr := os.Getenv(p + "_PORT") + portstr := os.Getenv(strings.ToUpper(p) + "_PORT") if portstr == "" { continue @@ -106,13 +106,11 @@ func main() { rProxyDir := path.Join(os.TempDir(), id) err := os.MkdirAll(rProxyDir, 0755) - if err != nil { log.Fatal(err) } err = os.WriteFile(path.Join(rProxyDir, "rproxy.bin"), RProxyBin, 0755) - if err != nil { log.Fatal(err) } @@ -120,7 +118,6 @@ func main() { defer os.RemoveAll(rProxyDir) c := exec.Command(path.Join(rProxyDir, "rproxy.bin"), rproxyArgs...) - stdout, err := c.StdoutPipe() if err != nil { log.Fatal(err) @@ -145,8 +142,7 @@ func main() { } }() - err = c.Start() - if err != nil { + if err := c.Start(); err != nil { log.Fatal(err) } @@ -154,9 +150,7 @@ func main() { log.Println("started rproxy") - s := &server{ - ms: ms, - } + s := &server{ms: ms} // create handlers r := http.NewServeMux() @@ -197,14 +191,12 @@ func main() { // start server log.Println("starting HTTP server") addr := fmt.Sprintf(":%d", ConfigPort) - err = http.ListenAndServe(addr, r) - if err != nil { + if err := http.ListenAndServe(addr, r); err != nil { log.Fatal(err) } } func (s *server) uploadHandler(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { w.WriteHeader(http.StatusBadRequest) return @@ -241,17 +233,20 @@ func (s *server) uploadHandler(w http.ResponseWriter, r *http.Request) { } res, err := s.ms.Upload(d.FunctionName, d.FunctionEnv, d.FunctionThreads, d.FunctionZip, envs) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) log.Println(err) + if errors.Is(err, manager.ErrInvalidFunctionName) { + w.WriteHeader(http.StatusBadRequest) + fmt.Fprintln(w, err) + return + } + w.WriteHeader(http.StatusInternalServerError) return } // return success w.WriteHeader(http.StatusOK) fmt.Fprint(w, res) - } func (s *server) deleteHandler(w http.ResponseWriter, r *http.Request) { @@ -320,7 +315,6 @@ func (s *server) wipeHandler(w http.ResponseWriter, r *http.Request) { } func (s *server) logsHandler(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodGet { w.WriteHeader(http.StatusBadRequest) return diff --git a/cmd/rproxy/main.go b/cmd/rproxy/main.go index 14a5fd8..0d59ab1 100644 --- a/cmd/rproxy/main.go +++ b/cmd/rproxy/main.go @@ -49,19 +49,13 @@ func main() { r := rproxy.New() - // CoAP if listenAddr, ok := listenAddrs["coap"]; ok { - log.Printf("starting coap server on %s", listenAddr) go coap.Start(r, listenAddr) } - // HTTP if listenAddr, ok := listenAddrs["http"]; ok { - log.Printf("starting http server on %s", listenAddr) go tfhttp.Start(r, listenAddr) } - // GRPC if listenAddr, ok := listenAddrs["grpc"]; ok { - log.Printf("starting grpc server on %s", listenAddr) go grpc.Start(r, listenAddr) } diff --git a/go.mod b/go.mod index dd03f0c..78e6a63 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,14 @@ require ( github.com/moby/moby/api v1.56.1 github.com/moby/moby/client v0.6.2 github.com/pfandzelter/go-coap v0.1.0 + github.com/prometheus/client_golang v1.25.0 google.golang.org/grpc v1.85.0 google.golang.org/protobuf v1.36.12 ) require ( github.com/Microsoft/go-winio v0.6.4 // indirect + github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect @@ -30,8 +32,12 @@ require ( github.com/moby/sys/sequential v0.7.0 // indirect github.com/moby/sys/user v0.5.0 // indirect github.com/moby/sys/userns v0.2.1 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/prometheus/client_model v0.6.3 // indirect + github.com/prometheus/common v0.72.0 // indirect + github.com/prometheus/procfs v0.22.0 // indirect github.com/sirupsen/logrus v1.10.2 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 // indirect diff --git a/go.sum b/go.sum index 2b21b4c..b5ab4f3 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8af github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Microsoft/go-winio v0.6.4 h1:kJF2pamtYCWXf0xAT8sAkwKC0pMl2HYBrRPHAqyUc+g= github.com/Microsoft/go-winio v0.6.4/go.mod h1:1xl5JXG4ze/m74GH6Dc4Mwxfc3VL5siRVQjIAlHH07U= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= @@ -51,12 +53,22 @@ github.com/moby/sys/user v0.5.0 h1:5+S4lyoavGyX1DGs68NW8xpx48T9+a7ogSUc0KjZg8Y= github.com/moby/sys/user v0.5.0/go.mod h1:4mQzP5aTmaLjDLp/dc870oNkik6E9vjRtWYwI05gvow= github.com/moby/sys/userns v0.2.1 h1:4OvdM7BcPkASbuouHsbW3aeMJSFlYDldBRnXVZhaRk8= github.com/moby/sys/userns v0.2.1/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pfandzelter/go-coap v0.1.0 h1:R6RqR3aTxJlnmuFDagiCJqXhN+WuwUoUS4+OY/pPnYY= github.com/pfandzelter/go-coap v0.1.0/go.mod h1:pNQG3knnPGxs+aCrGUdTDHqy1HqE9175DnhAomuVFM0= +github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0= +github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk= +github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo= +github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM= +github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4= +github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk= +github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics= +github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58= github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo= github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q= github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= @@ -77,6 +89,10 @@ go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= diff --git a/pkg/coap/coap.go b/pkg/coap/coap.go index 6d29d32..ec5fb15 100644 --- a/pkg/coap/coap.go +++ b/pkg/coap/coap.go @@ -11,7 +11,6 @@ import ( const async = false func Start(r *rproxy.RProxy, listenAddr string) { - h := coap.FuncHandler( func(l *net.UDPConn, a *net.UDPAddr, m *coap.Message) *coap.Message { @@ -52,6 +51,5 @@ func Start(r *rproxy.RProxy, listenAddr string) { }) log.Printf("Starting CoAP server on %s", listenAddr) - coap.ListenAndServe("udp", listenAddr, h) } diff --git a/pkg/docker/handler.go b/pkg/docker/handler.go index e485b41..379302b 100644 --- a/pkg/docker/handler.go +++ b/pkg/docker/handler.go @@ -1,3 +1,6 @@ +// Package docker implements a tinyFaaS backend that runs each function as a +// set of Docker containers. For every function it builds a dedicated image, +// creates a dedicated network and one container per requested thread. package docker import ( @@ -24,27 +27,39 @@ import ( ) const ( - TmpDir = "./tmp" + // TmpDir is the temporary folder where the build context of each function + // (runtime files + function code) is assembled. + TmpDir = "./tmp" + + // containerTimeout is the stop timeout in seconds. containerTimeout = 1 ) +// dockerHandler represents one deployed function. It implements manager.Handler +// and keeps track of every Docker resource created for it (image, network, +// containers) so they can be started and cleaned up later. type dockerHandler struct { - name string - env string - threads int - uniqueName string - filePath string - client *client.Client - network string - containers []string - handlerIPs []string + name string // function name as given by the user + env string // language runtime + threads int // number of container replicas + uniqueName string // name + UUID, used for image, network and containers + filePath string // temporary build folder + client *client.Client // Docker API client + network string // ID of the Docker network created for this function + containers []string // IDs of the containers created for this function + handlerIPs []string // IPs of the running containers, filled by Start } +// DockerBackend is the entry point of this package: it creates function +// handlers that run on the local Docker daemon. type DockerBackend struct { - client *client.Client - tinyFaaSID string + client *client.Client // Docker API client shared by all handlers + tinyFaaSID string // ID of this tinyFaaS instance, used as a resource label } +// New creates a DockerBackend. The Docker client is configured from the +// environment (DOCKER_HOST etc.) and negotiates the API version with the +// daemon. It aborts the program if the client cannot be created. func New(tinyFaaSID string) *DockerBackend { // create docker client client, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) @@ -53,19 +68,21 @@ func New(tinyFaaSID string) *DockerBackend { return nil } - return &DockerBackend{ - client: client, - tinyFaaSID: tinyFaaSID, - } + return &DockerBackend{client: client, tinyFaaSID: tinyFaaSID} } +// Stop is a no-op: there is nothing to release at backend level, since +// resources are cleaned up per function in Destroy. func (db *DockerBackend) Stop() error { return nil } +// Create prepares a function for execution: it assembles the build context, +// builds the Docker image, creates a dedicated network and creates (but does +// not start) one container per thread. Call Start on the returned handler to +// actually run the function. func (db *DockerBackend) Create(name string, env string, threads int, filedir string, envs map[string]string) (manager.Handler, error) { - - // make a unique function name by appending uuid string to function name + // Make a unique function name by appending uuid string to function name. uuid, err := uuid.NewRandom() if err != nil { return nil, err @@ -83,40 +100,34 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st dh.uniqueName = name + "-" + uuid.String() log.Println("creating function", name, "with unique name", dh.uniqueName) - // make a folder for the function - // mkdir + // Make a folder for the function (mkdir ). dh.filePath = path.Join(TmpDir, dh.uniqueName) - err = os.MkdirAll(dh.filePath, 0777) if err != nil { return nil, err } - // copy Docker stuff into folder - // cp runtimes//* - + // Copy Docker stuff into folder (cp runtimes//* ). Note the + // runtime files are embedded in the binary. err = util.CopyDirFromEmbed(runtimes, path.Join(runtimesDir, dh.env), dh.filePath) if err != nil { return nil, err } - log.Println("copied runtime files to folder", dh.filePath) - // copy function into folder - // into a subfolder called fn - // cp /fn + // Copy function into folder into a subfolder called fn (cp + // /fn). err = os.MkdirAll(path.Join(dh.filePath, "fn"), 0777) if err != nil { return nil, err } - err = util.CopyAll(filedir, path.Join(dh.filePath, "fn")) if err != nil { return nil, err } - // build image - // docker build -t + // Build image. The folder is sent to the daemon as a tar archive (the build + // context). Equivalent to docker build -t . tar, err := archive.TarWithOptions(dh.filePath, &archive.TarOptions{}) if err != nil { return nil, err @@ -127,8 +138,10 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st tar, client.ImageBuildOptions{ Tags: []string{dh.uniqueName}, - Remove: true, + Remove: true, // remove intermediate containers after the build Dockerfile: "Dockerfile", + // labels let us identify resources belonging to this function and + // to this tinyFaaS instance Labels: map[string]string{ "tinyfaas-function": dh.name, "tinyFaaS": db.tinyFaaSID, @@ -139,16 +152,16 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st return nil, err } + // Stream the build output to the log until the build finishes. defer r.Body.Close() scanner := bufio.NewScanner(r.Body) for scanner.Scan() { log.Println(scanner.Text()) } - log.Println("built image", dh.uniqueName) - // create network - // docker network create + // Create network, each function gets its own isolated network. Equivalent + // to: docker network create . network, err := db.client.NetworkCreate( context.Background(), dh.uniqueName, @@ -162,19 +175,17 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st if err != nil { return nil, err } - dh.network = network.ID - log.Println("created network", dh.uniqueName, "with id", network.ID) + // Convert the environment variable map to the "KEY=VALUE" format expected + // by Docker. e := make([]string, 0, len(envs)) - for k, v := range envs { e = append(e, fmt.Sprintf("%s=%s", k, v)) } - // create containers - // docker run -d --network --name + // Create containers. Equivalent to: docker run -d --network --name . for i := 0; i < dh.threads; i++ { c, err := db.client.ContainerCreate( context.Background(), @@ -188,44 +199,46 @@ func (db *DockerBackend) Create(name string, env string, threads int, filedir st Env: e, }, HostConfig: &container.HostConfig{ + // Attach the container to the function's own network. NetworkMode: container.NetworkMode(dh.uniqueName), }, + // Container names are suffixed with the replica index Name: dh.uniqueName + fmt.Sprintf("-%d", i), }, ) - if err != nil { return nil, err } - log.Println("created container", c.ID) dh.containers = append(dh.containers, c.ID) } - // remove folder - // rm -rf + // Remove the build context folder, since it is no longer needed once the + // image is built. err = os.RemoveAll(dh.filePath) if err != nil { return nil, err } - log.Println("removed folder", dh.filePath) return dh, nil } +// IPs returns the IP addresses of the function's containers. The list is +// populated by Start, so it is empty before the function has been started. func (dh *dockerHandler) IPs() []string { return dh.handlerIPs } +// Start launches all containers of the function, collects their IPs and waits +// until each of them reports it is healthy. It returns an error if a container +// does not become ready in time. func (dh *dockerHandler) Start() error { log.Printf("dh: %+v", dh) - // start containers - // docker start - + // Start containers. Equivalent to: docker start . wg := sync.WaitGroup{} for _, c := range dh.containers { wg.Add(1) @@ -246,8 +259,7 @@ func (dh *dockerHandler) Start() error { } wg.Wait() - // get container IPs - // docker inspect + // Get container IPs from the function's dedicated network. Equivalent to: docker inspect . for _, container := range dh.containers { c, err := dh.client.ContainerInspect( context.Background(), @@ -264,16 +276,13 @@ func (dh *dockerHandler) Start() error { log.Println("got ip", ip, "for container", container) } - // wait for the containers to be ready - // curl http://:8000/ready + // Wait for the containers to be ready. for i, ip := range dh.handlerIPs { log.Println("waiting for container", ip, "to be ready") maxRetries := 10 for { maxRetries-- if maxRetries == 0 { - // container did not start properly! - // give people some logs to look at log.Printf("container %s (ip %s) not ready after 10 retries", dh.containers[i], ip) log.Printf("getting logs for container %s", dh.containers[i]) logs, err := dh.getContainerLogs(dh.containers[i]) @@ -289,7 +298,6 @@ func (dh *dockerHandler) Start() error { return fmt.Errorf("container %s not ready after 10 retries", ip) } - // timeout of 1 second client := http.Client{ Timeout: 3 * time.Second, } @@ -302,6 +310,7 @@ func (dh *dockerHandler) Start() error { continue } resp.Body.Close() + // HTTP 200 means the function runtime is up and ready if resp.StatusCode == http.StatusOK { log.Println("container", ip, "is ready") break @@ -314,6 +323,8 @@ func (dh *dockerHandler) Start() error { return nil } +// Destroy removes everything created for the function: it stops and removes +// the containers (in parallel), then removes the network and the image. func (dh *dockerHandler) Destroy() error { log.Println("destroying function", dh.name) log.Printf("dh: %+v", dh) @@ -329,6 +340,7 @@ func (dh *dockerHandler) Destroy() error { timeout := 1 // seconds + // Equivalent to: docker stop . _, err := dh.client.ContainerStop( context.Background(), c, @@ -342,6 +354,7 @@ func (dh *dockerHandler) Destroy() error { log.Println("stopped container", c) + // Equivalent to: docker rm . _, err = dh.client.ContainerRemove( context.Background(), c, @@ -355,10 +368,12 @@ func (dh *dockerHandler) Destroy() error { log.Println("removed container", c) } + + // Wait for all containers to be stopped and removed; the network can only + // be deleted once no container is attached to it wg.Wait() - // remove network - // docker network rm + // Remove network. Equivalent to: docker network rm . _, err := dh.client.NetworkRemove( context.Background(), dh.network, @@ -370,8 +385,7 @@ func (dh *dockerHandler) Destroy() error { log.Println("removed network", dh.network) - // remove image - // docker rmi + // Remove image. Equivalent to: docker rmi . _, err = dh.client.ImageRemove( context.Background(), dh.uniqueName, @@ -387,9 +401,14 @@ func (dh *dockerHandler) Destroy() error { return nil } +// getContainerLogs returns the stdout and stderr logs of a single container. +// Every line is prefixed with the function name and container ID so that logs +// from different containers can be told apart. Stdout lines come first, +// followed by stderr lines. func (dh *dockerHandler) getContainerLogs(c string) (string, error) { logs := "" + // Equivalent to: docker logs --timestamps . l, err := dh.client.ContainerLogs( context.Background(), c, @@ -406,6 +425,8 @@ func (dh *dockerHandler) getContainerLogs(c string) (string, error) { var lstdout bytes.Buffer var lstderr bytes.Buffer + // Docker multiplexes stdout and stderr in a single stream. StdCopy + // demultiplexes them into two separate buffers. _, err = stdcopy.StdCopy(&lstdout, &lstderr, l) l.Close() @@ -414,8 +435,7 @@ func (dh *dockerHandler) getContainerLogs(c string) (string, error) { return logs, err } - // add a prefix to each line - // function= handler= + // Add a prefix to each line: function= handler= . scanner := bufio.NewScanner(&lstdout) for scanner.Scan() { @@ -426,7 +446,7 @@ func (dh *dockerHandler) getContainerLogs(c string) (string, error) { return logs, err } - // same for stderr + // Same for stderr. scanner = bufio.NewScanner(&lstderr) for scanner.Scan() { @@ -440,9 +460,10 @@ func (dh *dockerHandler) getContainerLogs(c string) (string, error) { return logs, nil } +// Logs returns the combined logs of all containers of the function as a single +// reader. func (dh *dockerHandler) Logs() (io.Reader, error) { - // get container logs - // docker logs + // Get container logs. Equivalent to: docker logs . var logs bytes.Buffer for _, c := range dh.containers { diff --git a/pkg/grpc/grpc.go b/pkg/grpc/grpc.go index 73ed25f..f73378a 100644 --- a/pkg/grpc/grpc.go +++ b/pkg/grpc/grpc.go @@ -19,7 +19,6 @@ type GRPCServer struct { // Request handles a request to the GRPC endpoint of the reverse-proxy of this tinyFaaS instance. func (gs *GRPCServer) Request(ctx context.Context, d *tinyfaas.Data) (*tinyfaas.Response, error) { - log.Printf("have request for path: %s (async: %v)", d.FunctionIdentifier, false) // Extract metadata from the gRPC context diff --git a/pkg/grpc/tinyfaas/tinyfaas.pb.go b/pkg/grpc/tinyfaas/tinyfaas.pb.go index 8f35772..d266a37 100644 --- a/pkg/grpc/tinyfaas/tinyfaas.pb.go +++ b/pkg/grpc/tinyfaas/tinyfaas.pb.go @@ -1,16 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v5.27.3 +// protoc-gen-go v1.36.12 +// protoc v7.36.2 // source: tinyfaas.proto package tinyfaas import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -21,21 +23,18 @@ const ( ) type Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - FunctionIdentifier string `protobuf:"bytes,1,opt,name=functionIdentifier,proto3" json:"functionIdentifier,omitempty"` - Data string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + FunctionIdentifier string `protobuf:"bytes,1,opt,name=functionIdentifier,proto3" json:"functionIdentifier,omitempty"` + Data string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Data) Reset() { *x = Data{} - if protoimpl.UnsafeEnabled { - mi := &file_tinyfaas_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_tinyfaas_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Data) String() string { @@ -46,7 +45,7 @@ func (*Data) ProtoMessage() {} func (x *Data) ProtoReflect() protoreflect.Message { mi := &file_tinyfaas_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -76,20 +75,17 @@ func (x *Data) GetData() string { } type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Response string `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` unknownFields protoimpl.UnknownFields - - Response string `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Response) Reset() { *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_tinyfaas_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_tinyfaas_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Response) String() string { @@ -100,7 +96,7 @@ func (*Response) ProtoMessage() {} func (x *Response) ProtoReflect() protoreflect.Message { mi := &file_tinyfaas_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -124,42 +120,32 @@ func (x *Response) GetResponse() string { var File_tinyfaas_proto protoreflect.FileDescriptor -var file_tinyfaas_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x1e, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6f, 0x67, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x74, - 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, 0x2e, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, - 0x22, 0x4a, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x12, 0x66, 0x75, 0x6e, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x26, 0x0a, 0x08, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x65, 0x0a, 0x08, 0x54, 0x69, 0x6e, 0x79, 0x46, 0x61, 0x61, 0x53, - 0x12, 0x59, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x2e, 0x6f, 0x70, - 0x65, 0x6e, 0x66, 0x6f, 0x67, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x74, 0x69, 0x6e, 0x79, 0x66, - 0x61, 0x61, 0x73, 0x2e, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x1a, 0x28, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6f, 0x67, 0x73, 0x74, 0x61, 0x63, 0x6b, - 0x2e, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, 0x2e, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, - 0x61, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, - 0x3b, 0x74, 0x69, 0x6e, 0x79, 0x66, 0x61, 0x61, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} +const file_tinyfaas_proto_rawDesc = "" + + "\n" + + "\x0etinyfaas.proto\x12\x1eopenfogstack.tinyfaas.tinyfaas\"J\n" + + "\x04Data\x12.\n" + + "\x12functionIdentifier\x18\x01 \x01(\tR\x12functionIdentifier\x12\x12\n" + + "\x04data\x18\x02 \x01(\tR\x04data\"&\n" + + "\bResponse\x12\x1a\n" + + "\bresponse\x18\x01 \x01(\tR\bresponse2e\n" + + "\bTinyFaaS\x12Y\n" + + "\aRequest\x12$.openfogstack.tinyfaas.tinyfaas.Data\x1a(.openfogstack.tinyfaas.tinyfaas.ResponseB\fZ\n" + + ".;tinyfaasb\x06proto3" var ( file_tinyfaas_proto_rawDescOnce sync.Once - file_tinyfaas_proto_rawDescData = file_tinyfaas_proto_rawDesc + file_tinyfaas_proto_rawDescData []byte ) func file_tinyfaas_proto_rawDescGZIP() []byte { file_tinyfaas_proto_rawDescOnce.Do(func() { - file_tinyfaas_proto_rawDescData = protoimpl.X.CompressGZIP(file_tinyfaas_proto_rawDescData) + file_tinyfaas_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_tinyfaas_proto_rawDesc), len(file_tinyfaas_proto_rawDesc))) }) return file_tinyfaas_proto_rawDescData } var file_tinyfaas_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_tinyfaas_proto_goTypes = []interface{}{ +var file_tinyfaas_proto_goTypes = []any{ (*Data)(nil), // 0: openfogstack.tinyfaas.tinyfaas.Data (*Response)(nil), // 1: openfogstack.tinyfaas.tinyfaas.Response } @@ -178,37 +164,11 @@ func file_tinyfaas_proto_init() { if File_tinyfaas_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_tinyfaas_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Data); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_tinyfaas_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_tinyfaas_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_tinyfaas_proto_rawDesc), len(file_tinyfaas_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -219,7 +179,6 @@ func file_tinyfaas_proto_init() { MessageInfos: file_tinyfaas_proto_msgTypes, }.Build() File_tinyfaas_proto = out.File - file_tinyfaas_proto_rawDesc = nil file_tinyfaas_proto_goTypes = nil file_tinyfaas_proto_depIdxs = nil } diff --git a/pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go b/pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go index 97f3fb7..f3fa95b 100644 --- a/pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go +++ b/pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go @@ -1,13 +1,14 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v5.27.3 +// - protoc-gen-go-grpc v1.6.2 +// - protoc v7.36.2 // source: tinyfaas.proto package tinyfaas import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -15,12 +16,18 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + TinyFaaS_Request_FullMethodName = "/openfogstack.tinyfaas.tinyfaas.TinyFaaS/Request" +) // TinyFaaSClient is the client API for TinyFaaS service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Represents a trigger node type TinyFaaSClient interface { Request(ctx context.Context, in *Data, opts ...grpc.CallOption) (*Response, error) } @@ -34,8 +41,9 @@ func NewTinyFaaSClient(cc grpc.ClientConnInterface) TinyFaaSClient { } func (c *tinyFaaSClient) Request(ctx context.Context, in *Data, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) - err := c.cc.Invoke(ctx, "/openfogstack.tinyfaas.tinyfaas.TinyFaaS/Request", in, out, opts...) + err := c.cc.Invoke(ctx, TinyFaaS_Request_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -44,18 +52,24 @@ func (c *tinyFaaSClient) Request(ctx context.Context, in *Data, opts ...grpc.Cal // TinyFaaSServer is the server API for TinyFaaS service. // All implementations should embed UnimplementedTinyFaaSServer -// for forward compatibility +// for forward compatibility. +// +// Represents a trigger node type TinyFaaSServer interface { Request(context.Context, *Data) (*Response, error) } -// UnimplementedTinyFaaSServer should be embedded to have forward compatible implementations. -type UnimplementedTinyFaaSServer struct { -} +// UnimplementedTinyFaaSServer should be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedTinyFaaSServer struct{} func (UnimplementedTinyFaaSServer) Request(context.Context, *Data) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method Request not implemented") + return nil, status.Error(codes.Unimplemented, "method Request not implemented") } +func (UnimplementedTinyFaaSServer) testEmbeddedByValue() {} // UnsafeTinyFaaSServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TinyFaaSServer will @@ -65,6 +79,13 @@ type UnsafeTinyFaaSServer interface { } func RegisterTinyFaaSServer(s grpc.ServiceRegistrar, srv TinyFaaSServer) { + // If the following call panics, it indicates UnimplementedTinyFaaSServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&TinyFaaS_ServiceDesc, srv) } @@ -78,7 +99,7 @@ func _TinyFaaS_Request_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/openfogstack.tinyfaas.tinyfaas.TinyFaaS/Request", + FullMethod: TinyFaaS_Request_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TinyFaaSServer).Request(ctx, req.(*Data)) diff --git a/pkg/http/http.go b/pkg/http/http.go index 81af12d..7253e98 100644 --- a/pkg/http/http.go +++ b/pkg/http/http.go @@ -9,7 +9,6 @@ import ( ) func Start(r *rproxy.RProxy, listenAddr string) { - mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { @@ -52,12 +51,8 @@ func Start(r *rproxy.RProxy, listenAddr string) { }) log.Printf("Starting HTTP server on %s", listenAddr) - err := http.ListenAndServe(listenAddr, mux) - - if err != nil { + if err := http.ListenAndServe(listenAddr, mux); err != nil { log.Fatal(err) } - log.Print("HTTP server stopped") - } diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 74ac99a..63f2578 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -21,6 +21,10 @@ const ( TmpDir = "./tmp" ) +// ErrInvalidFunctionName is returned when a function name contains +// non-alphanumeric characters. +var ErrInvalidFunctionName = errors.New("invalid function name") + type ManagementService struct { id string backend Backend @@ -44,7 +48,6 @@ type Handler interface { } func New(id string, rproxyListenAddress string, rproxyPort map[string]int, rproxyConfigPort int, tfBackend Backend) *ManagementService { - ms := &ManagementService{ id: id, backend: tfBackend, @@ -58,10 +61,9 @@ func New(id string, rproxyListenAddress string, rproxyPort map[string]int, rprox } func (ms *ManagementService) createFunction(name string, env string, threads int, funczip []byte, subfolderPath string, envs map[string]string) (string, error) { - // only allow alphanumeric characters if !util.IsAlphaNumeric(name) { - return "", fmt.Errorf("function name %s contains non-alphanumeric characters", name) + return "", fmt.Errorf("%w: %s contains non-alphanumeric characters", ErrInvalidFunctionName, name) } // make a uuidv4 for the function @@ -191,7 +193,6 @@ func (ms *ManagementService) createFunction(name string, env string, threads int } func (ms *ManagementService) Logs() (io.Reader, error) { - var logs bytes.Buffer for name := range ms.functionHandlers { @@ -212,7 +213,6 @@ func (ms *ManagementService) Logs() (io.Reader, error) { } func (ms *ManagementService) LogsFunction(name string) (io.Reader, error) { - fh, ok := ms.functionHandlers[name] if !ok { return nil, fmt.Errorf("function %s not found", name) @@ -239,7 +239,6 @@ func (ms *ManagementService) Wipe() error { return nil } func (ms *ManagementService) Delete(name string) error { - fh, ok := ms.functionHandlers[name] if !ok { return fmt.Errorf("function %s not found", name) @@ -295,41 +294,39 @@ func (ms *ManagementService) Delete(name string) error { } func (ms *ManagementService) Upload(name string, env string, threads int, zipped string, envs map[string]string) (string, error) { - // b64 decode zip zip, err := base64.StdEncoding.DecodeString(zipped) if err != nil { - // w.WriteHeader(http.StatusBadRequest) - log.Println(err) return "", err } // create function handler n, err := ms.createFunction(name, env, threads, zip, "", envs) - if err != nil { - // w.WriteHeader(http.StatusInternalServerError) - log.Println(err) return "", err } // return success - // w.WriteHeader(http.StatusOK) r := "" for prot, port := range ms.rproxyPort { - r += fmt.Sprintf("%s://%s:%d/%s\n", prot, ms.rproxyListenAddress, port, n) + // If ms.rproxyListenAddress is empty means that tinyFaaS accepts + // connection from any interface, including "localhost". We need to set + // this value to print a meaningful HTTP/COAP/gRPC address. + listenAddr := ms.rproxyListenAddress + if ms.rproxyListenAddress == "" { + listenAddr = "localhost" + } + + r += fmt.Sprintf("%s://%s:%d/%s\n", prot, listenAddr, port, n) } return r, nil } func (ms *ManagementService) UrlUpload(name string, env string, threads int, funcurl string, subfolder string, envs map[string]string) (string, error) { - // download url resp, err := http.Get(funcurl) if err != nil { - // w.WriteHeader(http.StatusBadRequest) - log.Println(err) return "", err } @@ -338,22 +335,16 @@ func (ms *ManagementService) UrlUpload(name string, env string, threads int, fun zip, err := io.ReadAll(resp.Body) if err != nil { - // w.WriteHeader(http.StatusBadRequest) - log.Println(err) return "", err } // create function handler n, err := ms.createFunction(name, env, threads, zip, subfolder, envs) - if err != nil { - // w.WriteHeader(http.StatusInternalServerError) - log.Println(err) return "", err } // return success - // w.WriteHeader(http.StatusOK) r := "" for prot, port := range ms.rproxyPort { r += fmt.Sprintf("%s://%s:%d/%s\n", prot, ms.rproxyListenAddress, port, n) diff --git a/pkg/rproxy/rproxy.go b/pkg/rproxy/rproxy.go index af4137f..394c343 100644 --- a/pkg/rproxy/rproxy.go +++ b/pkg/rproxy/rproxy.go @@ -9,6 +9,7 @@ import ( "net/http" "regexp" "sync" + "time" ) type Status uint32 @@ -90,11 +91,15 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin if async { log.Printf("async request accepted") go func() { + start := time.Now() resp, err2 := http.DefaultClient.Do(req) if err2 != nil { + observeInvocation(name, http.StatusBadGateway, true, time.Since(start)) return } + io.Copy(io.Discard, resp.Body) resp.Body.Close() + observeInvocation(name, resp.StatusCode, true, time.Since(start)) log.Printf("async request finished") }() return StatusAccepted, nil @@ -102,8 +107,10 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin // call function and return results log.Printf("sync request starting") + start := time.Now() resp, err := http.DefaultClient.Do(req) if err != nil { + observeInvocation(name, http.StatusBadGateway, false, time.Since(start)) log.Print(err) return StatusError, nil } @@ -112,14 +119,13 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin defer resp.Body.Close() res_body, err := io.ReadAll(resp.Body) + observeInvocation(name, resp.StatusCode, false, time.Since(start)) if err != nil { log.Print(err) return StatusError, nil } - // log.Printf("have response for sync request: %s", res_body) - return StatusOK, res_body } func cleanHeaderKey(key string) string { From 19beb9b4fd1d9eac95e6230d527da94f468ed2a0 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 11:18:17 +0000 Subject: [PATCH 10/14] Fix get_logs.sh I'm not sure whether this utility is still necessary, but in any case there was a problem with the network name. Since tinyFaaS creates the containers with a label, just use the label to filter them. --- scripts/get_logs.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/get_logs.sh b/scripts/get_logs.sh index 7be01c1..0b75164 100755 --- a/scripts/get_logs.sh +++ b/scripts/get_logs.sh @@ -2,8 +2,6 @@ set -e -for line in $(docker network ls --filter name=handler-net -q) ; do - for cont in $(docker ps -a -q --filter network="$line") ; do - docker logs "$cont" - done +for cont in $(docker ps -a -q --filter label=tinyfaas-function); do + docker logs "$cont" done From 7f43f109ba3879407e1f6f94daa889d252fdfb64 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 11:20:09 +0000 Subject: [PATCH 11/14] Add ref. to get_logs.sh in the README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 30f69bc..e14ab2b 100644 --- a/README.md +++ b/README.md @@ -133,9 +133,9 @@ To get a list of existing functions, run `./scripts/list.sh`. To delete a function, run `./scripts/delete.sh {NAME}`. To remove all functions, run `./scripts/wipe-functions.sh`. -To read the logs of all functions, run `./scripts/logs.sh`. The script does not -take any arguments. To read the logs of a single function, call the management -service directly with `curl "localhost:8080/logs?name={NAME}"`. +To read the logs of all functions, run `./scripts/logs.sh` or +`./scripts/get_logs.sh`. You can also ead the logs of a single function directly +with `curl "localhost:8080/logs?name={NAME}"`. ### Writing Functions From a1255e2966d242b050296945548d4aa3b5aa8e92 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Thu, 5 Nov 2026 11:22:58 +0000 Subject: [PATCH 12/14] Update blob when functionhandler.* is updated This fixes #51. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2abc056..21f6371 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ define runtime_build .PHONY: pkg/docker/runtimes-$(arch)/$(runtime) pkg/docker/runtimes-$(arch)/$(runtime): pkg/docker/runtimes-$(arch)/$(runtime)/Dockerfile pkg/docker/runtimes-$(arch)/$(runtime)/blob.tar.gz -pkg/docker/runtimes-$(arch)/$(runtime)/blob.tar.gz: pkg/docker/runtimes/$(runtime)/build.Dockerfile +pkg/docker/runtimes-$(arch)/$(runtime)/blob.tar.gz: pkg/docker/runtimes/$(runtime)/build.Dockerfile $(filter-out %/Dockerfile,$(wildcard pkg/docker/runtimes/$(runtime)/*)) mkdir -p $$(@D) cd $$( Date: Wed, 11 Nov 2026 13:26:51 +0000 Subject: [PATCH 13/14] Remove dead code from the rproxy --- pkg/rproxy/rproxy.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/rproxy/rproxy.go b/pkg/rproxy/rproxy.go index 394c343..8411546 100644 --- a/pkg/rproxy/rproxy.go +++ b/pkg/rproxy/rproxy.go @@ -9,7 +9,6 @@ import ( "net/http" "regexp" "sync" - "time" ) type Status uint32 @@ -91,15 +90,12 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin if async { log.Printf("async request accepted") go func() { - start := time.Now() resp, err2 := http.DefaultClient.Do(req) if err2 != nil { - observeInvocation(name, http.StatusBadGateway, true, time.Since(start)) return } io.Copy(io.Discard, resp.Body) resp.Body.Close() - observeInvocation(name, resp.StatusCode, true, time.Since(start)) log.Printf("async request finished") }() return StatusAccepted, nil @@ -107,10 +103,8 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin // call function and return results log.Printf("sync request starting") - start := time.Now() resp, err := http.DefaultClient.Do(req) if err != nil { - observeInvocation(name, http.StatusBadGateway, false, time.Since(start)) log.Print(err) return StatusError, nil } @@ -119,7 +113,6 @@ func (r *RProxy) Call(name string, payload []byte, async bool, headers map[strin defer resp.Body.Close() res_body, err := io.ReadAll(resp.Body) - observeInvocation(name, resp.StatusCode, false, time.Since(start)) if err != nil { log.Print(err) From 2a39099db68eaada16d2520748b797277886c831 Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 11 Nov 2026 13:27:19 +0000 Subject: [PATCH 14/14] Fix "make test" execution And also allow to execute tests with verbose option. --- Makefile | 13 ++++++++++--- README.md | 12 ++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 21f6371..c443787 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,19 @@ PROJECT_NAME := "tinyFaaS" PKG := "github.com/OpenFogStack/$(PROJECT_NAME)" GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v /ext/ | grep -v _test.go) + +# We need to get the python3 executable in this way because it also works with +# virtual environments when using sudo. +PYTHON ?= $(shell command -v python3) TEST_DIR := ./test +VERBOSE_TESTS ?= false +TEST_FLAGS := $(if $(filter true,$(VERBOSE_TESTS)),-v) SUPPORTED_ARCH=amd64 arm arm64 RUNTIMES := $(shell find pkg/docker/runtimes -name Dockerfile | xargs -n1 dirname | xargs -n1 basename) -# Some commands require root. +# Add "sudo" prefix on commands that require root. You can ovveride this +# (example with "doas" if sudo is not available). SUDO ?= $(if $(filter 0,$(shell id -u)),,sudo) OS=$(shell go env GOOS) @@ -24,7 +31,7 @@ start: tinyfaas-${OS}-${ARCH} .PHONY: test test: build ${TEST_DIR}/test_all.py pkg/grpc/tinyfaas/tinyfaas_pb2.py pkg/grpc/tinyfaas/tinyfaas_pb2.pyi pkg/grpc/tinyfaas/tinyfaas_pb2_grpc.py - @python3 ${TEST_DIR}/test_all.py + @$(SUDO) $(PYTHON) ${TEST_DIR}/test_all.py ${TEST_FLAGS} .PHONY: clean clean: clean.sh @@ -69,7 +76,7 @@ pkg/grpc/tinyfaas/tinyfaas.pb.go pkg/grpc/tinyfaas/tinyfaas_grpc.pb.go: pkg/grpc # requires grpcio-tools and mypy-protobuf # python3 -m pip install -r requirements.txt pkg/grpc/tinyfaas/tinyfaas_pb2.py pkg/grpc/tinyfaas/tinyfaas_pb2.pyi pkg/grpc/tinyfaas/tinyfaas_pb2_grpc.py: pkg/grpc/tinyfaas/tinyfaas.proto - @python3 -m grpc_tools.protoc -I $(