pipeline
pipeline copied to clipboard
Improve controller log message when non-existent variable
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
@cmoulliard could you please provider more information about user case? I guess this is an improvement to the admission webhook?
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" ...
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
/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.
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.