-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add example Pod to publish some tester messages #4
Comments
Derek assign: me |
It would be |
@alexellis i started on this in a separate repo (we can fold it in once it is correct) but I am not sure it is working as it should: https://github.com/LucasRoesler/nats-connector-example When I set 2019/12/28 22:39:20 Received topic: faas-req, message: Hello World
2019/12/28 22:39:20 Invoke function: pycho.openfaas-fn
2019/12/28 22:39:20 connector-sdk got result: [404] faas-req => pycho.openfaas-fn (40) bytes
[404] faas-req => pycho.openfaas-fn
Cannot find service: pycho.openfaas-fn. But, as you can see, the svc is there
When I set 2019/12/28 22:45:18 Received topic: faas-req, message: Hello World
2019/12/28 22:45:18 Invoke function: pycho.openfaas-fn
2019/12/28 22:45:18 connector-sdk got result: [202] faas-req => pycho.openfaas-fn (0) bytes
[202] faas-req => pycho.openfaas-fn Obviouslly in both cases I do not see any invocations of my function, the logs are completely empty I have already verified that the function is deployed and can be called both directly and async. The function works 100% as expected. I have built and pushed an image, so the instructions in the attached repo should work without needing to clone it. |
Thank you for writing the producer. Interesting error. I wonder if it's related to multiple namespaces? Is this the latest connector-sdk? @viveksyngh can you also take a look please? |
@alexellis and @viveksyngh i have updated the example/test repo to be pure openfaas functions now, see this branch https://github.com/LucasRoesler/nats-connector-example/tree/test-with-listener. I think this is easier to actually use for testing/verifying the connector behavior. Of course it still has the same exact issue as before, i.e. |
How are you deploying OpenFaaS @LucasRoesler? |
This was tested in KinD and in GKE. Both deployed using the latest helm chart with the default values. |
Ok, Kubernetes 👍 |
I tried running these test function with a fresh OpenFaaS installation on my local desktop.
Looks like |
I even tried the function present in the master branch instruction and I can see the function is getting called.
|
There seems to issue with invocation count not getting updated but I confirm from the logs that functions are getting called. |
That seems to be working as expected. What about without the async invoke? How did you do your install of OpenFaaS Vivek? |
I tried without async invoke as well. Seems to be working for me. Here is nats connector log.
|
I installed using helm chart. This is what I used for the installation
|
I deployed with k3sup and k3d (
For the functions @LucasRoesler it might be more intuitive to have something like this:
I was a bit confused by the names The example for Kafka is reasonably straight-forward: https://github.com/openfaas-incubator/kafka-connector#try-it-out - fortunately they already provided a tester that we could run. |
In the end The error message is while |
Strange.. the YAML file says
|
* Changes the example to use a completely different topic to prevent confusion with the NATS Streaming topic that OpenFaaS uses for async invocations. Ref: #4 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
Basically, what I was looking for was the equivalent of the following from @LucasRoesler' connector-test: nc, err := nats.Connect(natsURL)
if err != nil {
r := handler.Response{
Body: []byte(fmt.Sprintf("can not connect to nats: %s", err)),
StatusCode: http.StatusInternalServerError,
}
return r, err
}
defer nc.Close()
log.Printf("Sending \"%s\" to \"%s\"\n", msg, subject)
err = nc.Publish(subject, []byte(msg))
if err != nil {
log.Println(err)
r := handler.Response{
Body: []byte(fmt.Sprintf("can not publish to nats: %s", err)),
StatusCode: http.StatusInternalServerError,
}
return r, err
} Also, if you're not aware, Feel free to keep your repo, but would you be up for contributing the equivalent of above as a function into the repo? Might be best to use the legacy go template, or if an external template adds a lot of value, then the stack.yml file can now accept a list of templates to pull. When deploying I got an error and either of those options would make the experience a bit better. The CLI feature is relatively new, added by @martindekov. |
Please also see this change: dd4fdb0 |
Not sure what happened, but it is working now. In the $ kind create cluster
$ kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
$ helm upgrade openfaas --install openfaas/openfaas \
--namespace openfaas \
--set functionNamespace=openfaas-fn \
--set clusterRole=true \
--set generateBasicAuth=true
$ kubectl apply -f https://raw.githubusercontent.com/LucasRoesler/nats-connector-example/master/yaml/connector-dep.yaml
$ kubectl port-forward -n openfaas svc/gateway 8080:8080 &
$ faas-cli login --password $(kubectl -n openfaas get secret basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode)
$ faas-cli deploy
$ faas-cli invoke connector-test <<< "test message"
Success!
$ faas-cli logs connector-test
2019-12-29T19:06:50Z 2019/12/29 19:06:50 stderr: 2019/12/29 19:06:50 Sending "test message" to "faas-req"
2019-12-29T19:06:50Z 2019/12/29 19:06:50 stderr: 2019/12/29 19:06:50 Waiting for response
2019-12-29T19:06:50Z 2019/12/29 19:06:50 POST / - 200 OK - ContentLength: 8
$ faas-cli logs republish
2019-12-29T19:05:46Z Forking - ./handler []
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Started logging stderr from function.
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Started logging stdout from function.
2019-12-29T19:05:46Z 2019/12/29 19:05:46 OperationalMode: http
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Timeouts: read: 10s, write: 10s hard: 10s.
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Listening on port: 8080
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Writing lock-file to: /tmp/.lock
2019-12-29T19:05:46Z 2019/12/29 19:05:46 Metrics listening on port: 8081
2019-12-29T19:06:50Z 2019/12/29 19:06:50 stderr: 2019/12/29 19:06:50 Connecting to: nats://nats.openfaas:4222
2019-12-29T19:06:50Z 2019/12/29 19:06:50 POST / - 200 OK - ContentLength: 59
2019-12-29T19:06:50Z 2019/12/29 19:06:50 stderr: 2019/12/29 19:06:50 Publishing "test message" to: faas-resp |
@alexellis i can rename the functions but calling one publisher and one receiver isn't really accurate, unless you want me to remove the check that the correct message was received. If we do that, then we need to give instructions on how to do that actual verification via the To your comment about an external template, I don't understand what you mean by external templates, i am just using the To your comment about dd4fdb0 , I am not sure why your test attempt used the |
Just looking for a piece of code to publish a message and a function that receives it. No need for the full-duplex or send/receive etc for this repo, but feel free to keep the separate repo. I was just looking for 5-10 lines of code that could run in cluster and trigger the connector, sorry if I didn't explain that well enough in the issue. |
I will rewrite it |
@alexellis i rewrote that branch again, it is just a
|
I was able to confirm with the instructions @LucasRoesler posted, that the
For what it's worth, this was tested with:
|
Awesome, I will create a PR |
**What** - Add test publisher and receiver functions and instructions for how to use them to test the installations of the `nats-connector`. This should make the installation easier for users. Resolves openfaas#4 Signed-off-by: Lucas Roesler <[email protected]>
**What** - Add test publisher and receiver functions and instructions for how to use them to test the installations of the `nats-connector`. This should make the installation easier for users. Resolves #4 Signed-off-by: Lucas Roesler <[email protected]>
Description
There is no way included with the repo to test this connector, create a Go application and an example Pod that will publish some test messages. An OpenFaaS function using the classic Go template would also be fine.
Also change faas-request to another topic (nats-test?) so that it doesn't clash with the built-in NATS Streaming topic.
Update the README with how to test / use the connector.
Other connectors with examples:
This should be an absolute minimal example, simply to publish the input on the topic.
The text was updated successfully, but these errors were encountered: