zeerorg / cron-connector Goto Github PK
View Code? Open in Web Editor NEWA Cron Connector for OpenFaaS
License: MIT License
A Cron Connector for OpenFaaS
License: MIT License
Hi, it'd be great if you could move to use the latest version of the connector-sdk
https://github.com/openfaas-incubator/connector-sdk/
See the example for how to do that. It prevents duplication for one thing.
Once done, let me know so we can test it out and potentially list as a connector in the OpenFaaS docs.
Alex
Update docker images with specific tag.
Hi @zeerorg, @alexellis
Please see the function configuration and other details in below given repository,
https://github.com/satishtiwari23/openfaas.git
In order to reproduce, just create, build and deploy the hello-world template.
There are 2 issues:
After deploying 'hello-world-1' function, function is being added in cron-connctor and run on schedule time, but failing imeediately with below error:
2019/05/22 15:34:51 added function hello-world-1
2019/05/22 15:36:00 Executed function: hello-world-1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x606ae8]
goroutine 55 [running]:
github.com/zeerorg/cron-connector/types.CronFunction.InvokeFunction(0xc420060360, 0xc42006a770, 0xd, 0xc42006a7d0, 0xb, 0xc420062d80, 0x0, 0x0, 0x0)
/go/src/github.com/zeerorg/cron-connector/types/cron_function.go:105 +0x2d8
github.com/zeerorg/cron-connector/types.(*Scheduler).AddCronFunction.func1()
/go/src/github.com/zeerorg/cron-connector/types/scheduler.go:39 +0x15b
github.com/zeerorg/cron-connector/vendor/gopkg.in/robfig/cron%2ev2.FuncJob.Run(0xc4200ea9c0)
/go/src/github.com/zeerorg/cron-connector/vendor/gopkg.in/robfig/cron.v2/cron.go:94 +0x25
created by github.com/zeerorg/cron-connector/vendor/gopkg.in/robfig/cron%2ev2.(*Cron).run
/go/src/github.com/zeerorg/cron-connector/vendor/gopkg.in/robfig/cron.v2/cron.go:189 +0x2ab
The helm charts were added to the repo with PR #12 these should be published to a helm repository.
Updating deployment YAML files to apps/v1 is required for the helm chart - this is so users can deploy to K8s 1.16
Please can you take a look?
Hi @zeerorg
The package: https://github.com/zeerorg/cron-connector/tree/master/vendor/gopkg.in/robfig/cron.v2 is missing from your Gopkg.toml
Maybe you could rm -rf vendor Gopkg*
and run dep ensure
to rebuild it properly?
Alex
Create a set tag for specific version.
You should add a LICENSE so that people know how to consume / contribute to this code.
I'd suggest MIT.
I am successfully running cron-connector in conjunction with Faasd using the attached docker-compose.yml file (see below, copied from official Serverless for Everyone Else book).
Deploying functions with cron annotations works great:
annotations:
topic: cron-function
schedule: "*/1 * * * *"
As we can see in the cron-connector's logs:
$ sudo journalctl -f -u containerd | grep cron-connector
Jun 02 19:45:23 faasd openfaas:cron-connector[12716]: 2022/06/02 17:45:23 Gateway URL: http://gateway:8080
Jun 02 19:45:23 faasd openfaas:cron-connector[12716]: 2022/06/02 17:45:23 Async Invocation: false
Jun 02 19:45:33 faasd openfaas:cron-connector[12716]: 2022/06/02 17:45:33 Registered: golang.openfaas-fn [*/1 * * * *]
Jun 02 19:46:00 faasd openfaas:cron-connector[12716]: 2022/06/02 17:46:00 Executing function: golang.openfaas-fn
Jun 02 19:46:00 faasd openfaas:cron-connector[12716]: 2022/06/02 17:46:00 Response: golang [200]
However, as soon as I remove a function, there is an error:
...
Jun 02 20:36:00 faasd openfaas:cron-connector[15848]: 2022/06/02 18:36:00 Executing function: golang.openfaas-fn
Jun 02 20:36:00 faasd openfaas:cron-connector[15848]: 2022/06/02 18:36:00 Response: golang [200]
<other session: $ faas-cli remove golang>
Jun 02 20:36:14 faasd openfaas:cron-connector[15848]: Error: can't list functions: server returned unexpected status code: 500 - Metrics hander: unexpected status code retrieving functions from backend
Jun 02 20:36:14 faasd openfaas:cron-connector[15848]:
Once this happens, no functions is ever triggered by cron-connector anymore until executing: systemctl restart faasd
restart: always
policy on the cron-connector
docker-compose service does not help either.version: 1.0
provider:
name: openfaas
gateway: http://192.168.64.15:8080
functions:
golang:
lang: go
handler: ./golang
image: driescruyskens/golang:latest
annotations:
topic: cron-function
schedule: "*/1 * * * *"
version: "3.7"
services:
cron-connector:
image: "ghcr.io/openfaas/cron-connector:latest"
environment:
- gateway_url=http://gateway:8080
- basic_auth=true
- secret_mount_path=/run/secrets
volumes:
# we assume cwd == /var/lib/faasd
- type: bind
source: ./secrets/basic-auth-password
target: /run/secrets/basic-auth-password
- type: bind
source: ./secrets/basic-auth-user
target: /run/secrets/basic-auth-user
cap_add:
- CAP_NET_RAW
depends_on:
- gateway
basic-auth-plugin:
image: ghcr.io/openfaas/basic-auth:0.21.4
environment:
- port=8080
- secret_mount_path=/run/secrets
- user_filename=basic-auth-user
- pass_filename=basic-auth-password
volumes:
# we assume cwd == /var/lib/faasd
- type: bind
source: ./secrets/basic-auth-password
target: /run/secrets/basic-auth-password
- type: bind
source: ./secrets/basic-auth-user
target: /run/secrets/basic-auth-user
cap_add:
- CAP_NET_RAW
nats:
image: docker.io/library/nats-streaming:0.22.0
# nobody
user: "65534"
command:
- "/nats-streaming-server"
- "-m"
- "8222"
- "--store=file"
- "--dir=/nats"
- "--cluster_id=faas-cluster"
volumes:
# Data directory
- type: bind
source: ./nats
target: /nats
# ports:
# - "127.0.0.1:8222:8222"
prometheus:
image: docker.io/prom/prometheus:v2.14.0
# nobody
user: "65534"
volumes:
# Config directory
- type: bind
source: ./prometheus.yml
target: /etc/prometheus/prometheus.yml
# Data directory
- type: bind
source: ./prometheus
target: /prometheus
cap_add:
- CAP_NET_RAW
ports:
- "127.0.0.1:9090:9090"
gateway:
image: ghcr.io/openfaas/gateway:0.21.4
environment:
- basic_auth=true
- functions_provider_url=http://faasd-provider:8081/
- direct_functions=false
- read_timeout=60s
- write_timeout=60s
- upstream_timeout=65s
- faas_nats_address=nats
- faas_nats_port=4222
- auth_proxy_url=http://basic-auth-plugin:8080/validate
- auth_proxy_pass_body=false
- secret_mount_path=/run/secrets
- scale_from_zero=true
- function_namespace=openfaas-fn
volumes:
# we assume cwd == /var/lib/faasd
- type: bind
source: ./secrets/basic-auth-password
target: /run/secrets/basic-auth-password
- type: bind
source: ./secrets/basic-auth-user
target: /run/secrets/basic-auth-user
cap_add:
- CAP_NET_RAW
depends_on:
- basic-auth-plugin
- nats
- prometheus
ports:
- "8080:8080"
queue-worker:
image: ghcr.io/openfaas/queue-worker:0.12.2
environment:
- faas_nats_address=nats
- faas_nats_port=4222
- gateway_invoke=true
- faas_gateway_address=gateway
- ack_wait=5m5s
- max_inflight=1
- write_debug=false
- basic_auth=true
- secret_mount_path=/run/secrets
volumes:
# we assume cwd == /var/lib/faasd
- type: bind
source: ./secrets/basic-auth-password
target: /run/secrets/basic-auth-password
- type: bind
source: ./secrets/basic-auth-user
target: /run/secrets/basic-auth-user
cap_add:
- CAP_NET_RAW
depends_on:
- nats
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.