tektoncd / triggers

Event triggering with Tekton!
Apache License 2.0
553 stars 416 forks source link

Cron example no longer works. Eventlistener interface has changed? #986

Closed wstrange closed 3 years ago

wstrange commented 3 years ago

Triggering a pipeline using the cron example does not appear to work.

The cron performs:

 wget --spider  el-prod-listener:8080

# the response is:
Spider mode enabled. Check if remote file exists.
--2021-03-08 20:17:46--  http://el-prod-listener:8080/
Resolving el-prod-listener (el-prod-listener)... 10.0.7.224
Connecting to el-prod-listener (el-prod-listener)|10.0.7.224|:8080... connected.
HTTP request sent, awaiting response... 400 Bad Request
Remote file does not exist -- broken link!!!

It looks like recent additions to validate the event now expect a non empty payload:

https://github.com/tektoncd/triggers/blob/master/pkg/sink/validate_payload.go

Using curl gets me further:

curl -X POST --data '{}'  --header "Content-Type: application/json"   el-prod-listener:8080

The pipeline is triggered (good), but it looks like parameters set in the trigger template are not applied.

The pipeline fails to clone the git resource. This is from the TriggerTemplate:

     resources:
      - name: forgeops
        resourceSpec:
          type: git
          params:
          - name: revision
            value: $(params.gitrevision)
          - name: url
            value: $(params.gitrepositoryurl)

This same trigger template used to work prior to the v0.12.0. It looks like some default behavior has changed?

Additional Info

Kubernetes version:

 kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-21T20:23:45Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.15-gke.1102", GitCommit:"2e625a55a420ded12d04226c63c4cf415efc9cdb", GitTreeState:"clean", BuildDate:"2021-02-23T19:24:16Z", GoVersion:"go1.13.15b4", Compiler:"gc", Platform:"linux/amd64"} 
wstrange commented 3 years ago

The additional issue I encountered (not related to cron) is the parameter for the trigger template now requires the tt prefix:

Old param: $(params.gitrevision)

New Parameter $(tt.params.gitrevision)

wstrange commented 3 years ago

This worked for me:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: test-cronjob
spec:
  schedule: "10 9 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: trigger
            image: curlimages/curl
            args: ["curl", "-X", "POST" , "--data" ,"{}", "el-prod-listener:8080" ]
          restartPolicy: Never
dibyom commented 3 years ago

Thanks @wstrange

Sorry for the trouble. We made the params to tt.params change a while back so it is possible that this example was broken for a while (another issue that could be caught with #192 )

Seems like you have a working example now. Would you mind opening a PR with the fix?

wstrange commented 3 years ago

Yep - I'll create a PR.