openfaas-incubator / vcenter-connector

Extend vCenter with OpenFaaS
MIT License
28 stars 8 forks source link

Fail to launch Connector with flag provided but not defined: -vcenter-url #16

Closed lamw closed 5 years ago

lamw commented 5 years ago

Received flag provided but not defined: -vcenter-url error message when trying to start the connector based on the README instructions

root@photon-machine [ ~/go/src/github.com/vmware/govmomi/vcsim ]# ./vcsim -tls=false &
[1] 5510
root@photon-machine [ ~/go/src/github.com/vmware/govmomi/vcsim ]# export GOVC_URL=http://user:pass@127.0.0.1:8989/sdk GOVC_SIM_PID=5510

root@photon-machine [ ~/go/src/github.com/vmware/govmomi/vcsim ]# export GOVC_URL=http://user:pass@127.0.0.1:8989/sdk
root@photon-machine [ ~/go/src/github.com/vmware/govmomi/vcsim ]# export OPENFAAS_URL=http://127.0.0.1:31112
root@photon-machine [ ~/go/src/github.com/vmware/govmomi/vcsim ]# go run main.go -vcenter-url="http://user:pass@127.0.0.1:8989/sdk" -insecure
flag provided but not defined: -vcenter-url
Usage of /tmp/go-build946684473/b001/exe/main:
  -E string
        Output vcsim variables to the given fifo or stdout (default "-")
  -app int
        Number of virtual apps per compute resource
  -autostart
        Autostart model created VMs (default true)
  -cluster int
        Number of clusters (default 1)
  -dc int
        Number of datacenters (default 1)
  -delay int
        Method response delay across all methods
  -delay-jitter float
        Delay jitter coefficient of variation (tip: 0.5 is a good starting value)
  -ds int
        Number of local datastores (default 1)
  -esx
        Simulate standalone ESX
  -folder int
        Number of folders
  -host int
        Number of hosts per cluster (default 3)
  -httptest.serve string
        if non-empty, httptest.NewServer serves on this address and blocks
  -l string
        Listen address for vcsim (default "127.0.0.1:8989")
  -method-delay string
        Delay per method on the form 'method1:delay1,method2:delay2...'
  -pg int
        Number of port groups (default 1)
  -pod int
        Number of storage pods per datacenter
  -pool int
        Number of resource pools per compute resource
  -standalone-host int
        Number of standalone hosts (default 1)
  -tls
        Enable TLS (default true)
  -tlscert string
        Path to TLS certificate file
  -tlskey string
        Path to TLS key file
  -trace
        Trace SOAP to stderr
  -tunnel int
        SDK tunnel port (default -1)
  -vm int
        Number of virtual machines per resource pool (default 2)
exit status 2
alexellis commented 5 years ago

Hi @lamw from the output it looks like you're trying to run the connector in the vcsim folder which is why you see the error.

After the first step then do this:

cd $GOPATH/src/github.com/openfaas-incubator/vcenter-connector/
go build
./vcenter-connector

Does that help?

Alex

alexellis commented 5 years ago

( I've updated the instructions too )

lamw commented 5 years ago

Looks like the instructions for vcenter connector is missing from the README ...

Currently it just says:

export OPENFAAS_URL=http://127.0.0.1:31112
go run main.go -vcenter-url="http://user:pass@127.0.0.1:8989/sdk" -insecure

it should be

go get -u -d github.com/openfaas-incubator/vcenter-connector
cd $GOPATH/src/github.com/openfaas-incubator/vcenter-connector/
go build
./vcenter-connector -vcenter-url="http://user:pass@127.0.0.1:8989/sdk" -insecure

When I try to launch vCenter Connector, I get a new error:

root@photon-machine [ ~/go/src/github.com/openfaas-incubator/vcenter-connector ]# ./vcenter-connector -vcenter-url="http://user:pass@127.0.0.1:8989/sdk" -insecure
2019/01/25 20:49:27 Get http://127.0.0.1:31112/system/functions: dial tcp 127.0.0.1:31112: connect: connection refused

I did verify using curl -k http://user:pass@127.0.0.1:8989/about works, so govcsim is responding

alexellis commented 5 years ago

Do you have OpenFaaS deployed anywhere? That's what the URL is 127.0.0.1:31112

lamw commented 5 years ago

Oh, no. I had assumed the README was starting from scratch where you don't have anything running ...

alexellis commented 5 years ago

Let me add that too..

alexellis commented 5 years ago

https://github.com/openfaas-incubator/vcenter-connector/commit/cceb630ab5f1b5d9e518bd6e654dee6b8e666648

https://github.com/openfaas-incubator/vcenter-connector/commit/3edfcf4670a916636391ee4128b9ef3752822d96

lamw commented 5 years ago

Thanks! I've got OpenFaaS Cluster deployed (reachable to Admin UI)

I'm now getting error running:

root@photon-machine [ ~/echo-fn ]# faas-cli template store pull golang-http
Fetch templates from repository: https://github.com/openfaas-incubator/golang-http-template at master
2019/01/25 23:06:00 Attempting to expand templates from https://github.com/openfaas-incubator/golang-http-template
2019/01/25 23:06:01 Cannot overwrite the following 4 template(s): [golang-http golang-http-armhf golang-middleware golang-middleware-armhf]
2019/01/25 23:06:01 Fetched 0 template(s) : [] from https://github.com/openfaas-incubator/golang-http-template

I'm able to curl https://github.com/openfaas (so I know system can reach internet)

alexellis commented 5 years ago

You can skip this command if you already ran it and go onto faas-cli deploy

embano1 commented 5 years ago

@lamw can you please follow the steps described in this PR I created last night? https://github.com/openfaas-incubator/vcenter-connector/pull/17

This has all the bits and details to do correct event forwarding, incl. an example. If everything is up and running you can get some inspiration here (the Python example is also used in the README in the PR):

lamw commented 5 years ago

@embano1

Ran into an issue w/Step 5 ...

I'm able to reach OpenFaaS UI, so I assume OpenFaaS is working

root@photon-machine [ ~/pytagfn ]# faas-cli deploy -f stack.yml
Deploying: pytag-fn.

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

Function 'pytag-fn' failed to deploy with status code: 500

BTW - On Step 4, its not exactly clear to me if you want both Tag ID (URN) and if so, is it separated by comma or space, would be good to clarify that detail

embano1 commented 5 years ago

The function won't deploy so this is an issue with faas-cli not being able to connect to openfaas. Is the IP:Port correct for OpenFaaS? Can you please paste the stack.yaml?

Here's a working example regarding TAGURN:

provider:
  name: faas
  gateway: http://127.0.0.1:8080     # <- make sure this is correct for your environment
functions:
  pytag-fn:
    lang: python3
    handler: ./pytag-fn
    image: embano1/pytag-fn:0.1
    environment:
      VC: 192.168.178.72
      VCUSERNAME: user@vsphere.local
      VCPASSWORD: PassW0rd!
      TAGURN: urn:vmomi:InventoryServiceTag:019c0a9e-0672-48f5-ac2a-e394669e2916:GLOBAL
      TAGACTION: attach
      write_debug: true
      read_debug: true
    annotations:
      topic: vm.powered.on
lamw commented 5 years ago

I've got OpenFaaS running locally via Docker Swarm:

root@photon-machine [ ~/pytagfn ]# docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                NAMES
7c4fbc2aa6a0        openfaas/queue-worker:0.5.4   "./app"                  2 minutes ago       Up 2 minutes        8080/tcp             func_queue-worker.1.vxhl4bug2f1inr3yqn520gbpn
1137dc89ae53        nats-streaming:0.11.2         "/nats-streaming-s..."   2 minutes ago       Up 2 minutes        4222/tcp, 8222/tcp   func_nats.1.2cslkdahup5bf2pkdeoak3v1l
faca04565e9c        openfaas/faas-swarm:0.6.1     "./faas-swarm"           2 minutes ago       Up 2 minutes        8080/tcp             func_faas-swarm.1.yh4u8jlz2am7gg4p4m1kcp76o
04a8e28434f6        openfaas/gateway:0.9.14       "./gateway"              2 minutes ago       Up 2 minutes        8080/tcp             func_gateway.1.n7ffxeggh62k8wymeksbdsqwr
8732cd93ee95        prom/alertmanager:v0.15.0     "/bin/alertmanager..."   3 minutes ago       Up 2 minutes        9093/tcp             func_alertmanager.1.qp74l2tlliqodu7d7kvt52ity
0ee490e3ea96        prom/prometheus:v2.3.1        "/bin/prometheus -..."   3 minutes ago       Up 3 minutes        9090/tcp             func_prometheus.1.huy6bgbh2npnadfg664agdhza

I'm able to the UI which is published externally on 8080 (http://34.208.71.1:8080), so not sure how else to verify/check. Also, this is my first time really using OpenFaaS, so I could be missing something.

Here's my stack.yaml

provider:
  name: faas
  gateway: http://127.0.0.1:8080
functions:
  pytag-fn:
    lang: python3
    handler: ./pytag-fn
    image: embano1/pytag-fn:0.1
    environment:
      VC: 127.0.0.1:8989
      VCUSERNAME: u
      VCPASSWORD: p
      TAGURN: urn:vmomi:InventoryServiceTag:9d65bea5-f476-4c25-a8bd-0a7e2d051968:GLOBAL
      TAGACTION: attach
    annotations:
      topic: vm.powered.on
embano1 commented 5 years ago

As this related to troubleshooting to openfaas/CLI, it would be better to use Slack for this because we're off-topic here.

It looks like faas-cli is not able to connect to openfaas when deploying the function. Using localhost only works if openfaas gateway is also reachable on that address. According to your description, the gateway is at http://34.208.71.1:8080 so try changing the gateway address in stack.yaml to this.

To be honest, I also wonder why faas-cli uses this address/port Put http://127.0.0.1:31112/system/functions: dial tcp 127.0.0.1:31112? Where does 31112 come from? Is there a local redirect happening or old env var hanging around?

lamw commented 5 years ago

I'll reach out offline, I'm able to proceed a bit further but running into some other issues. I think it's due to the assumption of the instructions and depending on your experience and tools you're using.