Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about using AlpineFunction sample function #297

Closed
udondan opened this issue Oct 15, 2017 · 8 comments
Closed

Question about using AlpineFunction sample function #297

udondan opened this issue Oct 15, 2017 · 8 comments
Labels

Comments

@udondan
Copy link

udondan commented Oct 15, 2017

I am trying to convert a present Dockerfile into a FaaS function. I'm feeling like an idiot but I am not getting this to work. Failing with the simplest examples.

I tried this on CentOS and MacOS with the same results.

~/faas/sample-functions/AlpineFunction(master)$ ./build.sh
Sending build context to Docker daemon  6.144kB
Step 1/5 : FROM alpine:latest
latest: Pulling from library/alpine
Digest: sha256:f006ecbb824d87947d0b51ab8488634bf69fe4094959d935c0c103f4820a417d
Status: Downloaded newer image for alpine:latest
 ---> 76da55c8019d
Step 2/5 : ADD https://github.com/openfaas/faas/releases/download/0.6.5/fwatchdog /usr/bin
Downloading [==================================================>]  3.779MB/3.779MB
 ---> ece807143b7a
Step 3/5 : RUN chmod +x /usr/bin/fwatchdog
 ---> Running in dd57cc6b9e8d
 ---> c1e19230ec65
Removing intermediate container dd57cc6b9e8d
Step 4/5 : HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1
 ---> Running in a0cd65be6e00
 ---> 63a0e7acb5bb
Removing intermediate container a0cd65be6e00
Step 5/5 : CMD fwatchdog
 ---> Running in 34bd0c8a679d
 ---> c46cb76483bc
Removing intermediate container 34bd0c8a679d
Successfully built c46cb76483bc
Successfully tagged functions/alpine:latest

~/faas/sample-functions/AlpineFunction(master) $ faas-cli deploy --image=functions/alpine:latest --name=func_alpine_test
No existing service to remove
Deployed.
URL: http://localhost:8080/function/func_alpine_test

200 OK

$ faas-cli invoke func_alpine_test
Reading from STDIN - hit (Control + D) to stop.
Server returned unexpected status code: 500 - Can't reach service: func_alpine_test

$ docker service logs --no-trunc=true func_alpine_test
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 2017/10/15 14:16:21 Writing lock-file to: /tmp/.lock
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 2017/10/15 14:16:41 http: panic serving 10.0.0.5:38048: runtime error: invalid memory address or nil pointer dereference
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | goroutine 18 [running]:
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | net/http.(*conn).serve.func1(0xc420074300)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:1491 +0x12a
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | panic(0x634ba0, 0xc42000a030)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/runtime/panic.go:458 +0x243
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | main.pipeRequest(0xc42006c200, 0x7817c0, 0xc4200d8000, 0xc4200c40f0, 0xc42000a0b0, 0x4, 0x67b701)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/go/src/github.com/alexellis/faas/watchdog/main.go:145 +0x3db
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | main.makeRequestHandler.func1(0x7817c0, 0xc4200d8000, 0xc4200c40f0)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/go/src/github.com/alexellis/faas/watchdog/main.go:219 +0xe7
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | net/http.HandlerFunc.ServeHTTP(0xc42004ef60, 0x7817c0, 0xc4200d8000, 0xc4200c40f0)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:1726 +0x44
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | net/http.(*ServeMux).ServeHTTP(0x79bd40, 0x7817c0, 0xc4200d8000, 0xc4200c40f0)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:2022 +0x7f
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | net/http.serverHandler.ServeHTTP(0xc420074200, 0x7817c0, 0xc4200d8000, 0xc4200c40f0)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:2202 +0x7d
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | net/http.(*conn).serve(0xc420074300, 0x781d00, 0xc42006c500)
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:1579 +0x4b7
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | created by net/http.(*Server).Serve
func_alpine_test.1.tagfq6tcxmbaw958szm2ecnhn@moby    | 	/usr/local/go/src/net/http/server.go:2293 +0x44d

The same happens with other examples.

Expected Behaviour

Not failing

Current Behaviour

Failing, invoking a function shows:

Server returned unexpected status code: 500 - Can't reach service: func_alpine_test

Service log shows:

2017/10/15 14:16:41 http: panic serving 10.0.0.5:38048: runtime error: invalid memory address or nil pointer dereference

Possible Solution

Steps to Reproduce (for bugs)

  1. Clone openfaas/faas
  2. cd into sample-functions/AlpineFunction
  3. build
  4. deploy
  5. invoke
  6. Check service logs

Context

Your Environment

  • Docker version docker version (e.g. Docker 17.0.05 ):
$ docker version
Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:09 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:45:38 2017
 OS/Arch:      linux/amd64
 Experimental: false
  • faas-cli

    On CentOS:

$ faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: e804a60889e4d339762fb3643a315a173a963f26
Version: 0.4.18b

On MacOS:

$ faas-cli version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Commit: e804a60889e4d339762fb3643a315a173a963f26
Version: dev
  • Are you using Docker Swarm or Kubernetes (FaaS-netes)?

    Swarm, single node

  • Operating System and version (e.g. Linux, Windows, MacOS):

    MacOS 10.3 & CentOS 7.3.1611, same result

  • Link to your project or a code example to reproduce issue:

    No project, failing with included example functions.

@alexellis
Copy link
Member

Send your email to [email protected] and I'll invite you to slack. Someone should be able to help you there

@johnmccabe
Copy link
Contributor

@udondan I'm able to reproduce this locally, having a look into it now

@open-derek open-derek bot added bug and removed bug labels Oct 15, 2017
@johnmccabe
Copy link
Contributor

Derek add label: question

@open-derek open-derek bot added the question label Oct 15, 2017
@alexellis
Copy link
Member

Please try the tutorials or samples. Tutorials are in faas repo under the guide folder.

@johnmccabe
Copy link
Contributor

@udondan for your particular case I assume you're just attempting to run the basic provided function, in which case can you deploy with the following:

faas-cli deploy --image=functions/alpine:latest --name=func_alpine_test --fprocess="wc -l"

This will explicitly set the process to invoke in the function - have a look at the Dockerfile you can also see it there in a comment.

You should normally be able to just use the fprocess envvar in the image itself, but we currently have a bug (also spotted by @rgee0) in the CLI on deploy where it will set a default value thereby overriding the value set in the image - so for the moment deploying by explicitly setting it above should get you up and going. We'll raise a separate issue to track the CLI issue over in that repo.

@johnmccabe
Copy link
Contributor

johnmccabe commented Oct 15, 2017

@udondan there's a fix in the pipeline for the CLI issue, can you let us know if the suggestion above gets you moving in the meantime.

@alexellis alexellis changed the title Failing to get basic Dockerfile example working (invalid memory address or nil pointer dereference) Question about using AlpineFunction sample function Oct 15, 2017
@alexellis
Copy link
Member

alexellis commented Oct 15, 2017

@udondan - just had a chance to look at this. AlpineFunction is a base image that will allow you to run built-in busybox commands as serverless functions - or to which you can add your own code.

So this would not work:

faas-cli deploy --image=functions/alpine:latest --name=func_alpine_test

You'd need to derive a container, add your code or packages and set the fprocess (see Dockerfile for comments) or set the fprocess at deploy time through a CLI flag as explained by John

faas-cli deploy --image=functions/alpine:latest --name=func_alpine_test --fprocess="sha512sum"

fprocess is documented on the TestDrive.md file and also over on the watchdog README.md file in the watchdog folder.

https://github.com/openfaas/faas/blob/master/TestDrive.md

https://github.com/openfaas/faas/tree/master/watchdog

I'd suggest you follow one of the CLI tutorials first - https://github.com/openfaas/faas/tree/master/guide

I.e. first Go/Python function.

@udondan
Copy link
Author

udondan commented Oct 16, 2017

AlpineFunction is a base image that will allow you to run built-in busybox commands as serverless functions

Yes, that's what I was aiming for. :)

You should normally be able to just use the fprocess envvar in the image itself, but we currently have a bug (also spotted by @rgee0) in the CLI on deploy where it will set a default value thereby overriding the value set in the image - so for the moment deploying by explicitly setting it above should get you up and going. We'll raise a separate issue to track the CLI issue over in that repo.

This explain it. I started with my own Dockerfile and then reduced it step by step until I ended up with an empty Alpine image calling a system function. I then used the AlpineFunction Dockerfile in the sample folder and of course also tried with the fprocess uncommented.

So yes, passing the --fprocess along with the deploy succeeds.

Also tested openfaas/faas-cli#170 and that also works.

Thanks folks.

@udondan udondan closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants