hashicorp / faas-nomad

OpenFaaS plugin for Nomad
https://www.openfaas.com
MIT License
254 stars 46 forks source link

OpenFaaS gateway not running using faas.hcl #38

Closed samaitra closed 5 years ago

samaitra commented 6 years ago

What are the steps to reproduce this issue?

  1. source ./startNomad.sh
  2. nomad run ./nomad_job_files/faas.hcl
  3. nomad run ./nomad_job_files/monitoring.hcl
  4. faas-cli new gofunction -lang go
  5. update gofucntion.yml for the image name
  6. faas-cli build -yaml gofunction.yml
  7. faas-cli push -yaml gofunction.yml
  8. faas-cli deploy -yaml gofunction.yml

What happens?

Deploying: gofunction.

Is FaaS deployed? Do you need to specify the --gateway flag? Put http://127.0.0.1:8080/system/functions: dial tcp 127.0.0.1:8080: getsockopt: connection refused

What were you expecting to happen?

Deploying: gofunction. Removing old function. Deployed. URL: http://127.0.0.1:8080/function/gofunction

200 OK

Any other comments?

To resolve the issue I have observed that running docker swarm and deploy_stack from https://github.com/openfaas/faas works.

  1. docker swarm init
  2. ./deploy_stack.sh
alexesDev commented 5 years ago

I have same issue.

gateway stderr:

2019/02/19 08:41:38 Binding to external function provider: http://127.0.0.1:8081/
2019/02/19 08:41:38 Async enabled: Using NATS Streaming.
2019/02/19 08:41:38 Opening connection to nats://192.168.2.111:4222
2019/02/19 08:41:38 nats: no servers available for connection

nomadd stderr:

2019/02/19 08:43:20 The environment variable NOMAD_ADDR_http is deprecated please use the command line flag node_uri
2019/02/19 08:43:20 The environment variable NOMAD_REGION is deprecated please use the command line flag nomad_region
panic: interface conversion: interface {} is *errors.errorString, not string

goroutine 1 [running]:
github.com/hashicorp/go-hclog.(*intLogger).log(0xc000052ba0, 0xbf130e4a23768b6a, 0x24a592, 0xa695c0, 0x5, 0x7bdb28, 0x1d, 0xc0000f2870, 0x2, 0x1)
    /home/travis/gopath/pkg/mod/github.com/hashicorp/go-hclog@v0.0.0-20180828044259-75ecd6e6d645/int.go:227 +0xde8
github.com/hashicorp/go-hclog.(*intLogger).Log(0xc000052ba0, 0xc000000005, 0x7bdb28, 0x1d, 0xc0000f2870, 0x1, 0x1)
    /home/travis/gopath/pkg/mod/github.com/hashicorp/go-hclog@v0.0.0-20180828044259-75ecd6e6d645/int.go:105 +0x1b3
github.com/hashicorp/go-hclog.(*intLogger).Error(0xc000052ba0, 0x7bdb28, 0x1d, 0xc0000f2870, 0x1, 0x1)
    /home/travis/gopath/pkg/mod/github.com/hashicorp/go-hclog@v0.0.0-20180828044259-75ecd6e6d645/int.go:348 +0x65
main.makeDependencies(0x7ffd3cb99c29, 0xe, 0xc0000141d0, 0xe, 0x7ffd3cb99beb, 0x11, 0x7ffd3cb99c0a, 0x11, 0x0, 0x0, ...)
    /home/travis/gopath/src/github.com/hashicorp/faas-nomad/main.go:198 +0x46a
main.main()
    /home/travis/gopath/src/github.com/hashicorp/faas-nomad/main.go:123 +0xd0
acornies commented 5 years ago

Hi @alexesDev can you post your configuration for the gateway? What version of nats are you running?

alexesDev commented 5 years ago

@acornies I try to run https://raw.githubusercontent.com/hashicorp/faas-nomad/master/nomad_job_files/faas.hcl from https://www.hashicorp.com/blog/functions-as-a-service-with-nomad

acornies commented 5 years ago

@alexesDev I can't reproduce this using master version of this file. I've noticed that in your logs you have:

2019/02/19 08:41:38 Binding to external function provider: http://127.0.0.1:8081/
...
2019/02/19 08:41:38 Opening connection to nats://192.168.2.111:4222

suggesting that $NOMAD_IP_http renders as localhost which is derived from the bind interface setting in the agent. When compared to the output from the portable vagrant environment from this repo, I get:

2019/02/27 21:51:11 Binding to external function provider: http://192.168.50.2:8081/
2019/02/27 21:51:11 Async enabled: Using NATS Streaming.
2019/02/27 21:51:11 Opening connection to nats://192.168.50.2:4222

Can you post me your Nomad agent config?

samaitra commented 5 years ago

I have identified the issue, the original issue is due to incorrect OpenFaas gateway Ip address in gofunction.yml.

To resolve the issue you can run the following command

docker ps

The output will look something like below

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS                                                                                                                                                                                NAMES
a450fb66825f        b14005260b32        "./fwatchdog"            12 minutes ago      Up 12 minutes (healthy)   192.168.1.101:20131->8080/tcp, 192.168.1.101:20131->8080/udp                                                                                                                         gofunction-f167adaf-4a52-1d66-8372-83fb4ea1da37
1255639f5f40        5d1d85717268        "/run.sh"                About an hour ago   Up About an hour          192.168.1.101:3000->3000/tcp, 192.168.1.101:3000->3000/udp                                                                                                                           grafana-d6561156-4d19-f0fd-8cd6-99a6ecfd23d4
c7d13c237cbc        ea2af4e954f2        "./gateway"              2 hours ago         Up 2 hours                192.168.1.101:8080->8080/tcp, 192.168.1.101:8080->8080/udp                                                                                                                           gateway-b173e1b8-d806-51db-95d1-f57fc1ae24aa
474b8f419b31        30ee439fbdcf        "/bin/prometheus -co…"   2 hours ago         Up 2 hours                192.168.1.101:9090->9090/tcp, 192.168.1.101:9090->9090/udp                                                                                                                           prometheus-d6561156-4d19-f0fd-8cd6-99a6ecfd23d4
a082f3ec9708        e85877e6d2ce        "/bin/alertmanager -…"   2 hours ago         Up 2 hours                192.168.1.101:23913->9093/tcp, 192.168.1.101:23913->9093/udp                                                                                                                         alertmanager-d6561156-4d19-f0fd-8cd6-99a6ecfd23d4
23e8ffa3004b        fdbad19bf11e        "/nats-streaming-ser…"   2 hours ago         Up 2 hours                192.168.1.101:4222->4222/tcp, 192.168.1.101:4222->4222/udp, 192.168.1.101:6222->6222/tcp, 192.168.1.101:6222->6222/udp, 192.168.1.101:8222->8222/tcp, 192.168.1.101:8222->8222/udp   nats-b7053184-a0f6-7dd3-547c-b442553ade4e
9a1ce141d384        168d0defdbb2        "/bin/statsd_exporte…"   2 hours ago         Up 2 hours                192.168.1.101:9102->9102/tcp, 192.168.1.101:9102->9102/udp, 192.168.1.101:9125->9125/tcp, 192.168.1.101:9125->9125/udp                                                               statsd-b173e1b8-d806-51db-95d1-f57fc1ae24aa
c66f0c82c9a8        d03f413aa04b        "/home/faasnomad/faa…"   2 hours ago         Up 2 hours                192.168.1.101:8081->8080/tcp, 192.168.1.101:8081->8080/udp                                                                                                                           nomadd-b173e1b8-d806-51db-95d1-f57fc1ae24aa

Notice that gateway is running on 192.168.1.101:8080, so we will need to update the gofunction.yml like below

provider:
  name: faas
  gateway: http://192.168.1.101:8080
functions:
  gofunction:
    lang: go
    handler: ./gofunction
    image: username/gofunction