-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
updating doc to add note on task results #2538
Conversation
this is coming from today's API Work Group discussion here |
/hold discussed a bit in the API working group meeting today, but I'm not sure this is the right error for this situation. Also afaik this error only happens when something is trying to use the result that is missing, if a Task provides a result but doesn't and nothing consumes it, I don't think there is an error but there should be (I'm like 80% sure?) So I think instead we should change this behavior to be consistent and maybe use a different error. |
thanks @bobcatfish, I just verified that pipeline does not produce any error if a task is set to provide a result but none of the apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sum-two-ints
annotations:
description: |
A simple task that sums the two provided integers
spec:
params:
- name: a
type: string
default: "1"
description: The first integer
- name: b
type: string
default: "1"
description: The second integer
results:
- name: sum-result
description: The sum of the two provided integers
steps:
- name: sum
image: bash:latest
script: |
#!/usr/bin/env bash
echo $(params.a)
echo $(params.b)
echo -n $(( "$(params.a)" + "$(params.b)" )) | tee $(results.sum-result.path)
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: format-result
spec:
params:
- name: result
type: string
default: "0"
steps:
- name: print-sum
image: ubuntu
script: echo -n "*** Result = $(params.result) ***"
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: sum-and-print-pipeline
spec:
params:
- name: a
type: string
default: "1"
- name: b
type: string
default: "1"
tasks:
- name: sum-inputs
taskRef:
name: sum-two-ints
params:
- name: a
value: "$(params.a)"
- name: b
value: "$(params.b)"
- name: print-sum
taskRef:
name: format-result
params:
- name: result
value: "$(params.a)"
# value: "$(tasks.sum-inputs.results.sum-result)"
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: sum-and-print-pipeline-run
spec:
pipelineRef:
name: sum-and-print-pipeline
params:
- name: a
value: "100"
- name: b
value: "1000"
--- Pipeline exits with
Change this to produce validation failure ( Yup I agree the |
deeefeb
to
d65f702
Compare
d65f702
to
25b7b44
Compare
The following is the coverage report on the affected files.
|
@bobcatfish I have replaced the failure |
/approve |
Re-reading @bobcatfish's comment it sounds like we might want to update our TaskRun reconciler code to reject completed TaskRuns which haven't output all the results listed in the TaskSpec. The code which is pulling the results out of the termination log is here: https://github.com/tektoncd/pipeline/blob/master/pkg/reconciler/taskrun/taskrun.go#L606-L642 so it seems we could compare the given results to those in the spec and update the TaskRun's status to failed if they don't match? We could do this as part of this PR or in a separate one. @pritidesai @bobcatfish wdyt? |
/approve cancel Removing approve until we get consensus on what we want to do. |
@sbwsg @bobcatfish I could create a separate PR for TaskRun reconciler changes where
Also, after we change this behavior, |
We still need a PR for |
I created an issue to track this discussion and any pending PRs: #2701 |
Sounds good, this makes total sense to me!
Yeah I think you're right about that! One edge case: what if the Task does write a Result but chooses to make it an empty file? The TaskResult will be an empty string. Personally I think that's acceptable - the Task author has intentionally chosen to output a blank Result, rather than misnamed or forgotten to emit it.
I'm less sure about this one. If a Task produces Results but they go unused by any PipelineTasks or PipelineResults, I think that's fine. Example: a |
25b7b44
to
2a0d4e2
Compare
/kind misc |
I have reduced the scope down of this PR to change the error message from |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbwsg 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:
Approvers can indicate their approval by writing |
@pritidesai what is the status of this ? it needs a rebase 🙃 |
2a0d4e2
to
9855d17
Compare
/remove-kind misc |
sorry for delay @vdemeester its ready for review again |
This looks good to me but I've already approved. @tektoncd/core-maintainers anyone available to review and lgtm? |
pipeline exits with failure if receiving task can not resolve task results from dependent task.
9855d17
to
b3eec9e
Compare
Given the reduced scope of this change and the age of this PR I'm going to go ahead and assume there's no more feedback and give this an lgtm in addition to my approve earlier. /lgtm |
Thanks for following up @sbwsg - should there be a release note to go along with this? It seems like the implication is the user facing behavior is changing (if only slightly) |
Good thinking I've updated the release-note in the PR description. |
Changes
Task execution order is set such that the task producing a result is executed before the task referencing that result. In case of a failure of a referenced task, pipeline exits without executing the rest of the pipeline tasks. But when a referenced task succeeds but does not instantiate the result, the task with referencing result is not executed and pipeline fails. Pipeline exits with
InvalidTaskResultReference
since the result did not exist.An example of such task and pipeline execution here.
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.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes