Open richie-tt opened 4 years ago
Yes, nothing is wrong there. The cronjob trigger, by design, doesn't allow to modify the data to be sent, it's just a GET
request sent in the given schedule. Note that since there is no interaction with the cronjob, any logic to obtain some data can be encoded in the function itself.
Let us know if you have some specific use case in mind for having this data.
Hi @andresmgot
Thank you for your answer.
I will put more description of my use case because the purpose of the test example wast only to show missing transfer data from Trigger Cron to Function.
In Kubeless I build a function that communicates with Kubernetes API and on-base what event.Data
contain, it will create two different Pods.
I thought that Trigger Cronjob has implemented such functionality, according to the documentions or I miss something.
Thank you in advance for your reply
ah, sorry @1ricardo, you are correct, it's possible to set some data in the latest version of Kubeless. Are you running Kubeless v1.0.7 in your cluster? Also, is your trigger properly created? You can check it if you execute kubectl get cronjobtrigger -n kbox test -o yaml
.
Hi @andresmgot
I checked what you about asked:
so to be sure that I use the latest version I check configmaps of kubeless
❯ kubectl get configmaps -n kubeless -o yaml
apiVersion: v1
items:
- apiVersion: v1
data:
builder-image: kubeless/function-image-builder:v1.0.7
...
and here is result of kubectl get cronjobtrigger -n kbox test -o yaml
❯ kubectl get cronjobtrigger -n kbox test -o yaml
apiVersion: kubeless.io/v1beta1
kind: CronJobTrigger
metadata:
creationTimestamp: "2020-10-20T07:52:46Z"
finalizers:
- kubeless.io/cronjobtrigger
generation: 2
labels:
created-by: kubeless
name: test
namespace: kbox
resourceVersion: "23919434"
selfLink: /apis/kubeless.io/v1beta1/namespaces/kbox/cronjobtriggers/test
uid: b0ee8a64-8b36-47f0-ae92-b21eec5de46d
spec:
function-name: test
schedule: '*/1 * * * *'
br
Got it, I am able to reproduce it. It seems that the problem is that even if the CLI is able to parse the payload
you are giving:
▶ kubeless trigger cronjob create foo --function get-python-37 -f f.json --dryrun --schedule '* * * * *' -o yaml
apiVersion: kubeless.io/v1beta1
kind: CronJobTrigger
metadata:
creationTimestamp: null
labels:
created-by: kubeless
name: foo
namespace: default
spec:
function-name: get-python-37
payload:
f: b
schedule: '* * * * *'
When creating it, in the cluster, it loses the payload
property:
▶ kubeless trigger cronjob create foo --function get-python-37 -f f.json --schedule '* * * * *'
INFO[0000] Cronjob trigger foo created in namespace default successfully!
▶ kubectl get cronjobtrigger foo -o yaml
apiVersion: kubeless.io/v1beta1
kind: CronJobTrigger
metadata:
creationTimestamp: "2020-10-22T09:02:57Z"
finalizers:
- kubeless.io/cronjobtrigger
generation: 2
labels:
created-by: kubeless
name: foo
namespace: default
resourceVersion: "2643761"
selfLink: /apis/kubeless.io/v1beta1/namespaces/default/cronjobtriggers/foo
uid: fbd94c72-73df-4ea5-9b60-7c6a683c0ad9
spec:
function-name: get-python-37
schedule: '* * * * *'
Adding @delucca to the thread. You contributed this feature. Are you able to reproduce the issue? Would you mind taking a look?
@andresmgot here is the commit where I've added the payload
to the kubeless trigger cronjob create
command: kubeless#78d3ce
Since our workflow uses Gitops and we don't create resources directly from the CLI in our cluster, chances are that I forgot to test the deployment from the CLI directly to the cluster, and tested it only with the --dry-run
flag. I think that must be an easy fix.
This week I'm deploying a new service, so I'll only be able to take a look at it in the weekend. If this issue is not time-sensitve I'll gladly fix it ;)
Thanks a lot, @delucca @andresm for taking the time and looking at this matter
Hi @delucca @andresmgot
I would like to ask you if there is any progress on that.
I will really appreciate any information or you can give me a tip on what field I should add to cron job trigger
in Kubernetes so I can move forward with my project.
Thank you in advance
BR
@1ricardo as a workaround, you can edit your trigger and add the payload
field manually:
kubectl edit cronjobtrigger <name>
...
spec:
function-name: test
schedule: '*/1 * * * *'
payload:
foo: bar
Hi,
I noticed that
event.Data
is empty when it is triggered by payload of CronJob.I create my test function:
kubeless function deploy test -n kbox --runtime go1.14 --from-file test.go --handler test.Handler --dependencies go.mod
source of file test.go
then I created the Trigger cronjob:
kubeless trigger cronjob create -n kbox test --function test -f test.json --schedule "*/1 * * * *"
source of test.jsonthe logs from pod
test-6747bdf7b6-mz96f
show thatevent.Data
is emptyCan You please give me tip what I am doing wrong here.
Thank you in advance.