Files
fn-serverless/Makefile
Reed Allman 3a9c48b8a3 http-stream format (#1202)
* POC code for inotify UDS-io-socket

* http-stream format

introducing the `http-stream` format support in fn. there are many details for
this, none of which can be linked from github :( -- docs are coming (I could
even try to add some here?). this is kinda MVP-ish level, but does not
implement the remaining spec, ie 'headers' fixing up / invoke fixing up. the
thinking being we can land this to test fdks / cli with and start splitting
work up on top of this. all other formats work the same as previous (no
breakage, only new stuff)

with the cli you can set `format: http-stream` and deploy, and then invoke a
function via the `http-stream` format. this uses unix domain socket (uds) on
the container instead of previous stdin/stdout, and fdks will have to support
this in a new fashion (will see about getting docs on here). fdk-go works,
which is here: https://github.com/fnproject/fdk-go/pull/30 . the output looks
the same as an http format function when invoking a function. wahoo.

there's some amount of stuff we can clean up here, enumerated:

* the cleanup of the sock files is iffy, high pri here

* permissions are a pain in the ass and i punted on dealing with them. you can
run `sudo ./fnserver` if running locally, it may/may not work in dind(?) ootb

* no pipe usage at all (yay), still could reduce buffer usage around the pipe
behavior, we could clean this up potentially before removal (and tests)

* my brain can’t figure out if dispatchOldFormats changes pipe behavior, but
tests work

* i marked XXX to do some clean up which will follow soon… need this to test fdk
tho so meh, any thoughts on those marked would be appreciated however (1 less
decision for me). mostly happy w/ general shape/plumbing tho

* there are no tests atm, this is a tricky dance indeed. attempts were made.
need to futz with the permission stuff before committing to adding any tests
here, which I don't like either. also, need to get the fdk-go based test image
updated according to the fdk-go, and there's a dance there too. rumba time..

* delaying the big big cleanup until we have good enough fdk support to kill
all the other formats.

open to ideas on how to maneuver landing stuff...

* fix unmount

* see if the tests work on ci...

* add call id header

* fix up makefile

* add configurable iofs opts

* add format file describing http-stream contract

* rm some cruft

* default iofs to /tmp, remove mounting

out of the box fn we can't mount. /tmp will provide a memory backed fs for us
on most systems, this will be fine for local developing and this can be
configured to be wherever for anyone that wants to make things more difficult
for themselves.

also removes the mounting, this has to be done as root. we can't do this in
the oss fn (short of requesting root, but no). in the future, we may want to
have a knob here to have a function that can be configured in fn that allows
further configuration here. since we don't know what we need in this dept
really, not doing that yet (it may be the case that it could be done
operationally outside of fn, eg, but not if each directory needs to be
configured itself, which seems likely, anyway...)

* add WIP note just in case...
2018-09-14 10:59:12 +01:00

137 lines
3.4 KiB
Makefile

# Just builds
.PHONY: dep
dep:
dep ensure --vendor-only
.PHONY: dep-up
dep-up:
dep ensure
.PHONY: build
build:
go build -o fnserver ./cmd/fnserver
.PHONY: generate
generate: api/agent/grpc/runner.pb.go
.PHONY: install
install:
go build -o ${GOPATH}/bin/fnserver ./cmd/fnserver
.PHONY: checkfmt
checkfmt:
./go-fmt.sh
.PHONY: clear-images
clear-images:
-docker images -q -f dangling=true | xargs docker rmi -f
for i in fnproject/fn-test-utils fnproject/fn-status-checker fnproject/hello fnproject/dind fnproject/fnserver ; do \
docker images "$$i" --format '{{ .ID }}\t{{ .Repository }}\t{{ .Tag}}' | while read id repo tag; do \
if [ "$$tag" = "<none>" ]; then docker rmi "$$id"; else docker rmi "$$repo:$$tag"; fi; done; done
.PHONY: release-fnserver
release-fnserver:
./release.sh
.PHONY: build-dind
build-dind:
(cd images/dind && ./build.sh)
.PHONY: release-dind
release-dind:
(cd images/dind && ./release.sh)
.PHONY: fn-status-checker
fn-status-checker: checkfmt
cd images/fn-status-checker && ./build.sh
.PHONY: fn-test-utils
fn-test-utils: checkfmt
cd images/fn-test-utils && ./build.sh
.PHONY: test-middleware
test-middleware: test-basic
cd examples/middleware && go build
.PHONY: test-extensions
test-extensions: test-basic
cd examples/extensions && go build
.PHONY: test-basic
test-basic: checkfmt pull-images fn-test-utils fn-status-checker
./test.sh
.PHONY: test
test: checkfmt pull-images test-basic test-middleware test-extensions test-system
.PHONY: test-system
test-system: test-basic
./system_test.sh sqlite3
./system_test.sh mysql
./system_test.sh postgres
.PHONY: img-busybox
img-busybox:
docker pull busybox
.PHONY: img-hello
img-hello:
docker pull fnproject/hello
.PHONY: img-mysql
img-mysql:
/bin/bash -c "source ./helpers.sh && docker_pull_mysql"
.PHONY: img-postgres
img-postgres:
/bin/bash -c "source ./helpers.sh && docker_pull_postgres"
.PHONY: img-minio
img-minio:
/bin/bash -c "source ./helpers.sh && docker_pull_minio"
.PHONY: pull-images
pull-images: img-hello img-mysql img-postgres img-minio img-busybox
.PHONY: test-datastore
test-datastore:
cd api/datastore && go test -v ./...
.PHONY: test-log-datastore
test-log-datastore:
cd api/logs && go test -v ./...
.PHONY: test-build-arm
test-build-arm:
GOARCH=arm GOARM=5 $(MAKE) build
GOARCH=arm GOARM=6 $(MAKE) build
GOARCH=arm GOARM=7 $(MAKE) build
GOARCH=arm64 $(MAKE) build
%.pb.go: %.proto
protoc --proto_path=$(@D) --proto_path=./vendor --go_out=plugins=grpc:$(@D) $<
.PHONY: run
run: build
GIN_MODE=debug ./fnserver
.PHONY: docker-build
docker-build:
docker build --build-arg HTTPS_PROXY --build-arg HTTP_PROXY -t fnproject/fnserver:latest .
.PHONY: docker-run
docker-run: docker-build
docker run --rm --privileged -it -e NO_PROXY -e HTTP_PROXY -e FN_LOG_LEVEL=debug -e "FN_DB_URL=sqlite3:///app/data/fn.db" -v ${CURDIR}/data:/app/data -p 8080:8080 fnproject/fnserver
.PHONY: docker-test
docker-test:
docker run -ti --privileged --rm -e FN_LOG_LEVEL=debug \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${CURDIR}:/go/src/github.com/fnproject/fn \
-w /go/src/github.com/fnproject/fn \
fnproject/go:dev go test \
-v $(shell docker run --rm -ti -v ${CURDIR}:/go/src/github.com/fnproject/fn -w /go/src/github.com/fnproject/fn -e GOPATH=/go golang:alpine sh -c 'go list ./... | grep -v vendor | grep -v examples | grep -v tool | grep -v fn')
.PHONY: all
all: dep generate build