Git Product home page Git Product logo

cron-connector's People

Contributors

alexellis avatar zeerorg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cron-connector's Issues

runtime error: invalid memory address or nil pointer dereference

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:

  1. cron connector is crashing with below mentioned error at the time execution( function is being run continuously even after error)
  2. if we schedule 2 functions, both are being added to cron connector but second is being run twice and failed immediately with same error.

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

Publish Helm chart

The helm charts were added to the repo with PR #12 these should be published to a helm repository.

Update to apps/v1

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?

Add LICENSE

You should add a LICENSE so that people know how to consume / contribute to this code.

I'd suggest MIT.

cron-connector container stops working after removing a function (faasd)

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

  • The same happens when removing the function using the gateway UI instead of the CLI.
  • Setting a restart: always policy on the cron-connector docker-compose service does not help either.
  • It doesn't matter if there are functions left to run or not, deleting 1 function triggers the error.
  • I am not able to track this error message to a particular line in the cron-connector's source code..
stack.yml
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 * * * *"
docker-compose file
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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.