tektoncd / experimental

Experimental Tekton Components
Apache License 2.0
100 stars 121 forks source link

[CEL] Upgrade to tekton/pipeline version v0.44 #943

Closed ScrapCodes closed 1 year ago

ScrapCodes commented 1 year ago

Changes

1. Migrate to customrun for the entire CEL codebase, including examples.
2. Update tekton version and related dependencies
3. Update the Readme to indicate that CEL has migrated
   v1beta1.CustomRuns and last commit that supports v1alpha1.Run.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

See the contribution guide for more details.

Tomcli commented 1 year ago

Not sure can the custom task reconcile both v1alpha1 and v1beta1 for this migration? If not we might want to have the commit number in the readme for the ones who still want to run custom task in v1alpha1 api.

ScrapCodes commented 1 year ago

While testing I have found following case to be not working.

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: pipelinerun-
spec:
  pipelineSpec:
    params:
    - name: is-red-expr
      type: string
    tasks:
      - name: is-red
        taskRef:
          apiVersion: cel.tekton.dev/v1alpha1
          kind: CEL
        params:
          - name: is-red-expr
            value: “$(params.is-red-expr)"
  params:
    - name: is-red-expr
      value: "{'blue': 0x000080, 'red': 0xFF0000}['red'] == 0xFF0000"

Error:

{"level":"error","logger":"cel-controller","caller":"cel/celrun.go:102","msg":"CEL expression is-red-expr could not be parsed when reconciling CustomRun default/pipelinerun-kkw4z-is-red: ERROR: <input>:1:1: Syntax error: token recognition error at: '“'\n | “{'blue': 0x000080, 'red': 0xFF0000}['red'] == 0xFF0000\"\n | ^\nERROR: <input>:1:56: Syntax error: token recognition error at: '\"'\n | “{'blue': 0x000080, 'red': 0xFF0000}['red'] == 0xFF0000\"\n | .......................................................^","commit":"7205f5d-dirty","knative.dev/controller":"github.com.tektoncd.experimental.cel.pkg.reconciler.cel.Reconciler","knative.dev/kind":"tekton.dev.CustomRun","knative.dev/traceid":"5c064244-2d5f-45ca-aa48-85a680c3e331","knative.dev/key":"default/pipelinerun-kkw4z-is-red","stacktrace":"github.com/tektoncd/experimental/cel/pkg/reconciler/cel.(*Reconciler).ReconcileKind\n\tgithub.com/tektoncd/experimental/cel/pkg/reconciler/cel/celrun.go:102\ngithub.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/customrun.(*reconcilerImpl).Reconcile\n\tgithub.com/tektoncd/pipeline@v0.44.0/pkg/client/injection/reconciler/pipeline/v1beta1/customrun/reconciler.go:239\nknative.dev/pkg/controller.(*Impl).processNextWorkItem\n\tknative.dev/pkg@v0.0.0-20221123011842-b78020c16606/controller/controller.go:542\nknative.dev/pkg/controller.(*Impl).RunContext.func3\n\tknative.dev/pkg@v0.0.0-20221123011842-b78020c16606/controller/controller.go:491"}

Following example works:

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: pipelinerun-
spec:
  pipelineSpec:
    tasks:
      - name: get-blue
        taskRef:
          apiVersion: cel.tekton.dev/v1alpha1
          kind: CEL
        params:
          - name: blue
            value: "{'blue': 0x000080, 'red': 0xFF0000}['red'] == 0xFF0000"

Is this related to parameter substitution?

ScrapCodes commented 1 year ago

When "$(params.is-red-expr)" was replaced by $(params.is-red-expr), it started working.

Tomcli commented 1 year ago

Hi @jerop @pritidesai can you review this PR? Thanks.

XinruZhang commented 1 year ago

/lgtm

Thank you @ScrapCodes !

tekton-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, XinruZhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[cel/OWNERS](https://github.com/tektoncd/experimental/blob/main/cel/OWNERS)~~ [jerop] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment