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

Improve controller log message when non-existent variable #8265

Open
cmoulliard opened this issue Sep 16, 2024 · 5 comments
Open

Improve controller log message when non-existent variable #8265

cmoulliard opened this issue Sep 16, 2024 · 5 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@cmoulliard
Copy link

cmoulliard commented Sep 16, 2024

Todo

Improve the controller log message when non-existent variable is discovered:

Tekton Controller has reported this error: admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: non-existent variable in "#!/usr/bin/env bash\nset -eu\nset -o ...
...

See : Gist link

Such an issue can occur if a results param is missing (e.g. results.IMAGE_REF.path) from the Task Spec definition

IMAGE_REF: $(cat /var/workdir/IMAGE_REF)\"\ncat /var/workdir/IMAGE_REF > \"$(results.IMAGE_REF.path)\"\n\n
"": spec.pipelineSpec.tasks[3].taskSpec.steps[0].script

To reproduce the issue, deploy the following PipelineRun

apiVersion: "tekton.dev/v1"
kind: "PipelineRun"
metadata:
  annotations:
    tekton.dev/pipelines.minVersion: "0.60.x"
    tekton.dev/displayName: "Simple example of a Tekton pipeline echoing a message\
      \ and pushing a result"
    tekton.dev/platforms: "linux/amd64"
  labels:
    app.kubernetes.io/version: "0.1"
  name: "simple-job-results-file-script"
spec:
  pipelineSpec:
    tasks:
    - name: "say-hello"
      taskSpec:
        #results:
        #- description: "A Foo user"
        #  name: "FOO"
        steps:
        - image: "registry.access.redhat.com/ubi9@sha256:1ee4d8c50d14d9c9e9229d9a039d793fcbc9aa803806d194c957a397cf1d2b17"
          name: "run-script"
          script: |-
            #!/usr/bin/env bash

            set -e
            echo "-------------------------------------"
            echo "Say Hello" | tee "$(results.FOO.path)"
            echo "-------------------------------------"

then the controller will report

Error from server (BadRequest): error when creating "out/flows/tekton/example/pipelinerun-simple-job-results-file-script.yaml": admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: non-existent variable in "#!/usr/bin/env bash\n\nset -e\necho \"-------------------------------------\"\necho \"Say Hello\" | tee \"$(results.FOO.path)\"\necho \"-------------------------------------\"": spec.pipelineSpec.tasks[0].taskSpec.steps[0].script

Remark: The bash script of my example is pretty basic but when it is bigger than a few lines, it is almost impossible for a user to figure out what the issue is

@chengjoey
Copy link
Member

@cmoulliard could you please provider more information about user case? I guess this is an improvement to the admission webhook?

@cmoulliard
Copy link
Author

I guess this is an improvement to the admission webhook?

Yes as mentioned at the beginning of the Error => Tekton Controller has reported this error: admission webhook "validation.webhook.pipeline.tekton.dev" ...

@cmoulliard
Copy link
Author

cmoulliard commented Sep 23, 2024

could you please provider more information about user case?

The use case is pretty simple. If a taskSpec part of a pipelineRun which executes a bash script is missing a result declaration, then the error I reported will take place.

See the test case I created within the issue's description @chengjoey

@chengjoey
Copy link
Member

/assign

i got what you mean, currently admission-webhook works fine because results.FOO is not defined, but the script is so long that it is hard to get what variable is missing.

@vdemeester vdemeester added the kind/bug Categorizes issue or PR as related to a bug. label Oct 15, 2024
@RobertDiebels
Copy link

Would like to add that this is also relevant for regular parameters of a Task. The log does not state which parameter is missing, just that one is missing. In a script that has over a hundred lines that becomes a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants