Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not patch pipelinerun labels #44

Open
liangyuanpeng opened this issue May 9, 2023 · 4 comments
Open

Can not patch pipelinerun labels #44

liangyuanpeng opened this issue May 9, 2023 · 4 comments
Assignees

Comments

@liangyuanpeng
Copy link

liangyuanpeng commented May 9, 2023

Log

1.683615978721644e+09   INFO    controller.run-filter   Inspecting BuildRun instance for Tekton's CustomRun ownership   {"generation": 1, "namespace": "default", "name": "trigger-bhfwt"}
1.6836159789839964e+09  ERROR   trying to update PipelineRun metadata   {"controller": "pipelinerun", "controllerGroup": "tekton.dev", "controllerKind": "PipelineRun", "PipelineRun": {"name":"test","namespace":"default"}, "namespace": "default", "name": "test", "reconcileID": "b67e91b4-9bed-4bfc-908e-5f4e646d6208", "error": "PipelineRun.tekton.dev \"test\" is invalid: metadata.labels: Invalid value: \"trigger-bhfwt,test-prbbl\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')"}
github.com/shipwright-io/triggers/controllers.(*PipelineRunReconciler).Reconcile
        /home/lan/repo/git/shipwright/triggers/controllers/pipelinerun_controller.go:183
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:121
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:320
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:273
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:234
1.6836159789841447e+09  ERROR   Reconciler error        {"controller": "pipelinerun", "controllerGroup": "tekton.dev", "controllerKind": "PipelineRun", "PipelineRun": {"name":"test","namespace":"default"}, "namespace": "default", "name": "test", "reconcileID": "b67e91b4-9bed-4bfc-908e-5f4e646d6208", "error": "PipelineRun.tekton.dev \"test\" is invalid: metadata.labels: Invalid value: \"trigger-bhfwt,test-prbbl\": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:326
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:273
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /home/lan/repo/git/shipwright/triggers/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:234
1.68361597900475e+09    INFO    Searching for Builds matching criteria  {"controller": "pipelinerun", "controllerGroup": "tekton.dev", "controllerKind": "PipelineRun", "PipelineRun": {"name":"test","namespace":"default"}, "namespace": "default", "name": "test", "reconcileID": "f10f1cc7-41bf-46e3-aa83-6b0b0f34613f", "ref-name": "nodejs-ex", "ref-status": ["Succeeded"], "ref-selector": {"tekton.dev/pipeline":"nodejs-ex"}}

Checked

name: "PipelineRun with BuildRun labeled",
pipelineRun: pipelineRunLabeled,
buildRunsIssued: []string{"buildrun"},
want: "buildrun,existing-buildrun",

Seems like this is the design but it's not working.

It is giving pipelinerun patch labels if I understand correctly, just like:

lan@lan:~/repo/git/shipwright/triggers$ kubectl patch pipelinerun test --type='merge' -p '{"metadata":{"labels":{"hello":"world,world2"}}}'
The PipelineRun "test" is invalid: metadata.labels: Invalid value: "world,world2": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')

Versions

shipwright build: 0.11.0
tekton: v0.44.0
trigger: main

Reproduce

  1. base env (shipwright build, tekton and trigger)
  2. apply buildstrategy of ko
  3. Change output.image in demo.yaml
  4. create secret for output.credentials.name in demo.yaml (maybe not need, have not run this step.)
  5. kubectl apply demo.yaml

demo.yaml

---
apiVersion: shipwright.io/v1alpha1
kind: Build
metadata:
  name: trigger
spec:
  trigger:
    when:
      - name: nodejs-ex pipeline has succeeded
        type: Pipeline
        objectRef:
          name: nodejs-ex
          status:
            - Succeeded
  paramValues:
    - name: go-flags
      value: "-v -mod=vendor -ldflags=-w"
    - name: go-version
      value: "1.19"
    - name: package-directory
      value: ./cmd/shipwright-build-controller
  source:
    url: https://github.com/shipwright-io/build
  strategy:
    name: ko
    kind: ClusterBuildStrategy
  output:
    image: {owner}/shipwright-build
    credentials:
      name: push-secret

---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: nodejs-ex
spec:
  tasks:
    - name: shipwright
      taskSpec:
        steps:
          - name: echo
            image: alpine
            script: |
              #!/bin/sh
              echo "Hello nodejs-ex"
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: test
spec:
  pipelineRef:
    name: nodejs-ex

cc author @otaviof

Remind me if i missed something,Thanks :)

I want to work for it if someone can provide more detail for it and it's the wrong thing.

@qu1queee
Copy link
Contributor

qu1queee commented May 9, 2023

@otaviof can u help here?

@otaviof
Copy link
Member

otaviof commented May 10, 2023

Let me have a look at it, please.

/assign @otaviof

@liangyuanpeng
Copy link
Author

liangyuanpeng commented May 17, 2023

I can not reproduce it now, not sure what's happen.

It have not error but also have not trigger to a new buildrun when pipeline nodejs-ex is successed.

lan@lan:~/server/cdf/shipwright/yamls$ k get buildrun -A
NAMESPACE   NAME            SUCCEEDED   REASON   STARTTIME   COMPLETIONTIME
default     trigger-nmrmk 

Error on shipwright-build:

{"level":"error","ts":1684317447.3220704,"logger":"controller.buildrun-controller","msg":"Reconciler error","name":"trigger-nmrmk","namespace":"default","error":"admission webhook \"validation.webhook.pipeline.tekton.dev\" denied the request: validation failed: non-existent variable in \"$(params.shp-output-directory)\": spec.steps[2].env[PARAM_OUTPUT_DIRECTORY]","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"debug","ts":1684317488.2823372,"logger":"controller.buildrun-controller","msg":"starting reconciling request from a BuildRun or TaskRun event","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}
{"level":"info","ts":1684317488.282584,"logger":"controller.buildrun-controller","msg":"updating BuildRun status","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}
{"level":"info","ts":1684317488.2888117,"logger":"controller.buildrun-controller","msg":"falling back to default serviceAccount","name":"trigger-nmrmk","namespace":"default","namespace":"default"}
{"level":"debug","ts":1684317488.288843,"logger":"controller.buildrun-controller","msg":"retrieving ClusterBuildStrategy","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger"}
{"level":"info","ts":1684317488.289151,"logger":"controller.buildrun-controller","msg":"creating TaskRun from BuildRun","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk-","BuildRun":"trigger-nmrmk"}
{"level":"error","ts":1684317488.3081229,"logger":"controller.buildrun-controller","msg":"Reconciler error","name":"trigger-nmrmk","namespace":"default","error":"admission webhook \"validation.webhook.pipeline.tekton.dev\" denied the request: validation failed: non-existent variable in \"$(params.shp-output-directory)\": spec.steps[2].env[PARAM_OUTPUT_DIRECTORY]","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"debug","ts":1684317570.2287133,"logger":"controller.buildrun-controller","msg":"starting reconciling request from a BuildRun or TaskRun event","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}

@liangyuanpeng
Copy link
Author

I can not reproduce it now, not sure what's happen.

It have not error but also have not trigger to a new buildrun when pipeline nodejs-ex is successed.

lan@lan:~/server/cdf/shipwright/yamls$ k get buildrun -A
NAMESPACE   NAME            SUCCEEDED   REASON   STARTTIME   COMPLETIONTIME
default     trigger-nmrmk 

Error on shipwright-build:

{"level":"error","ts":1684317447.3220704,"logger":"controller.buildrun-controller","msg":"Reconciler error","name":"trigger-nmrmk","namespace":"default","error":"admission webhook \"validation.webhook.pipeline.tekton.dev\" denied the request: validation failed: non-existent variable in \"$(params.shp-output-directory)\": spec.steps[2].env[PARAM_OUTPUT_DIRECTORY]","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"debug","ts":1684317488.2823372,"logger":"controller.buildrun-controller","msg":"starting reconciling request from a BuildRun or TaskRun event","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}
{"level":"info","ts":1684317488.282584,"logger":"controller.buildrun-controller","msg":"updating BuildRun status","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}
{"level":"info","ts":1684317488.2888117,"logger":"controller.buildrun-controller","msg":"falling back to default serviceAccount","name":"trigger-nmrmk","namespace":"default","namespace":"default"}
{"level":"debug","ts":1684317488.288843,"logger":"controller.buildrun-controller","msg":"retrieving ClusterBuildStrategy","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger"}
{"level":"info","ts":1684317488.289151,"logger":"controller.buildrun-controller","msg":"creating TaskRun from BuildRun","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk-","BuildRun":"trigger-nmrmk"}
{"level":"error","ts":1684317488.3081229,"logger":"controller.buildrun-controller","msg":"Reconciler error","name":"trigger-nmrmk","namespace":"default","error":"admission webhook \"validation.webhook.pipeline.tekton.dev\" denied the request: validation failed: non-existent variable in \"$(params.shp-output-directory)\": spec.steps[2].env[PARAM_OUTPUT_DIRECTORY]","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227"}
{"level":"debug","ts":1684317570.2287133,"logger":"controller.buildrun-controller","msg":"starting reconciling request from a BuildRun or TaskRun event","name":"trigger-nmrmk","namespace":"default","namespace":"default","name":"trigger-nmrmk"}

It's some problem of shipwright v0.11.0 work with tekton v0.44.0 , tested shipwright main and it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants