openfaas / cron-connector

Invoke functions on a schedule.
MIT License
39 stars 10 forks source link

The latest version cron-connector doesn't invoke the functions with Faasd #18

Closed speedymonster closed 3 years ago

speedymonster commented 3 years ago

My actions before raising this issue

Expected Behaviour

it should invoke the functions in the given time.

Current Behaviour

It is not invoking the functions. "added function {function name} in {namespace}", {namespace} is not being printed on screen. ns= empty image

Possible Solution

When I use the Cron-connector version 0.3.1 the function is invoked correctly. Dockerhub

Steps to Reproduce (for bugs)

  1. Edited /var/lib/faasd/docker-compose.yaml and added Cron-connector service.
  2. Restarted the Faasd services
  3. Created a new function with the indicated annotation image

Context

I am trying to create a function with a cron, but it is not invoked at the time indicated in the 'schedule' annotation. image

Environment

alexellis commented 3 years ago

I'm a bit suspicious of the JSON screenshot.

Can you show that the example provided in the book didn't work? And use faas-cli to deploy and annotate it.

Perhaps you are submitting JSON to the API no incorrectly, so let's rule that out first and use the 5 min Cron option too.

Alex

alexellis commented 3 years ago

It is claiming to invoke the function. Did the gateway confirm that?

@viveksyngh can you take a look please?

alexellis commented 3 years ago

@speedymonster just a suggestion here. I see you're not using TLS for your faasd installation, it's highly recommended since it is on the Internet, so traffic would then be encrypted. See the chapter on Caddy for this.

I've asked Vivek to look at the connector, but I would like you to test with the instructions in the book also, so we can rule out your custom code etc.

alexellis commented 3 years ago

I don't think that invocations are working either, this is the testing that I did with the example from the book with an expression of * * * * * which runs every minute:

ubuntu@faasd:~$ sudo journalctl -t openfaas:cron-connector  -f
-- Logs begin at Wed 2021-07-14 12:01:26 BST. --
Jul 14 12:09:59 faasd openfaas:cron-connector[10324]: 2021/07/14 11:09:59 Version: 63646e5f5c917160ea4185d17dcdfeca2511169d        Commit: 0.4.2
Jul 14 12:09:59 faasd openfaas:cron-connector[10324]: 2021/07/14 11:09:59 Gateway URL:  http://gateway:8080
Jul 14 12:09:59 faasd openfaas:cron-connector[10324]: 2021/07/14 11:09:59 Async Invocation:  false
Jul 14 12:10:09 faasd openfaas:cron-connector[10324]: 2021/07/14 11:10:09 added function nodeinfo in 
Jul 14 12:14:29 faasd openfaas:cron-connector[10324]: 2021/07/14 11:14:29 deleted function nodeinfo in 
Jul 14 12:14:29 faasd openfaas:cron-connector[10324]: 2021/07/14 11:14:29 added function nodeinfo in 
Jul 14 12:15:00 faasd openfaas:cron-connector[10324]: 2021/07/14 11:15:00 Executed function: nodeinfo (ns=)
Jul 14 12:16:00 faasd openfaas:cron-connector[10324]: 2021/07/14 11:16:00 Executed function: nodeinfo (ns=)
Jul 14 12:17:00 faasd openfaas:cron-connector[10324]: 2021/07/14 11:17:00 Executed function: nodeinfo (ns=)
^C
ubuntu@faasd:~$ logout
Connection to 10.143.143.36 closed.
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli list
Function                        Invocations     Replicas
nodeinfo                        1               1    
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli list
Function                        Invocations     Replicas
nodeinfo                        1               1    
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli list
Function                        Invocations     Replicas
nodeinfo                        1               1    
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli list
Function                        Invocations     Replicas
nodeinfo                        1               1    
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli list
Function                        Invocations     Replicas
nodeinfo                        1               1    
alex@alex-nuc8:~/go/src/github.com/alexellis/serverless-for-everyone-else$ faas-cli logs nodeinfo
WARNING! You are not using an encrypted connection to the gateway, consider using HTTPS.
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Version: 0.8.4 SHA: bbd2e96214264d6b87cc97745ee9f604776dd80f
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Forking: node, arguments: [index.js]
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Started logging: stderr from function.
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Started logging: stdout from function.
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Watchdog mode: http
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Timeouts: read: 15s, write: 15s hard: 10s.
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Listening on port: 8080
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Writing lock-file to: /tmp/.lock
2021-07-14T11:10:08Z 2021/07/14 11:10:08 Metrics listening on port: 8081
2021-07-14T11:10:08Z node12 listening on port: 3000
2021-07-14T11:10:22Z 2021/07/14 11:10:22 GET / - 200 OK - ContentLength: 85
2021-07-14T11:14:21Z 2021/07/14 11:14:21 SIGTERM received.. shutting down server in 15s
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Removing lock-file : /tmp/.lock
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Forked function has terminated: signal: terminated
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Version: 0.8.4 SHA: bbd2e96214264d6b87cc97745ee9f604776dd80f
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Forking: node, arguments: [index.js]
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Started logging: stderr from function.
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Started logging: stdout from function.
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Watchdog mode: http
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Timeouts: read: 15s, write: 15s hard: 10s.
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Listening on port: 8080
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Writing lock-file to: /tmp/.lock
2021-07-14T11:14:21Z 2021/07/14 11:14:21 Metrics listening on port: 8081
2021-07-14T11:14:21Z node12 listening on port: 3000
speedymonster commented 3 years ago

I'm a bit suspicious of the JSON screenshot.

Can you show that the example provided in the book didn't work? And use faas-cli to deploy and annotate it.

Perhaps you are submitting JSON to the API no incorrectly, so let's rule that out first and use the 5 min Cron option too.

Alex

I tried deployment by REST API and faas-cli

alexellis commented 3 years ago

@speedymonster you're all set now, plus I tidied up the error messages and it now prints response codes into the logs to show you what's happening.

Enjoy, and do become a GitHub Sponsor on whatever tier makes sense for you, so that you can support us as we work hard for you and other users.

https://github.com/sponsors/alexellis/ https://github.com/sponsors/openfaas/