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

[TEP-0076] Add array support for emitting results #4818

Merged
merged 1 commit into from May 25, 2022

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 2, 2022

Changes

This is part of work in TEP-0076
This commit provides support for emitting array results. Previous to
this commit we have changed the TaskResults Type to support array. But we can only emit string type result.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

Support array type for emitting results from a task as an alpha feature.

The type of the result is changed from string to ArrayOrString.

A task can specify a type to produce array result, such as:

  results:
    - name: array-results
      type: array
      description: The array results

And the task script can populate result in an array form with:

echo -n "[\"hello\",\"world\"]" | tee $(results.array-results.path)

 This feature is part of the TEP-0076 and its in progress to index into the array result while consuming that result.

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 2, 2022
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 2, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 66.7% -3.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 95.1% 94.0% -1.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 66.7% -3.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 95.1% 94.0% -1.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 66.7% -3.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 95.1% 94.0% -1.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 66.7% -3.0
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 95.1% 94.0% -1.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

logger.Fatalf("Error while handling results: %s", err)
}
}

return err
}

func (e Entrypointer) readResultsFromDisk() error {
func (e Entrypointer) readResultsFromDisk(resultDir string) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for better unit testing. Without this I think we cannot create "tekton/results" dir to emit results

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 94.7% -3.4
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@ywluogg
Copy link
Contributor

ywluogg commented May 3, 2022

/assign ywluogg

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 95.2% 1.4

@@ -39,7 +39,7 @@ type TaskRunResult struct {
Type ResultsType `json:"type,omitempty"`

// Value the given value of the result
Value string `json:"value"`
Value ArrayOrString `json:"value"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a API change to me. It seems like we need to follow https://github.com/tektoncd/pipeline/blob/main/api_compatibility_policy.md#alpha-beta-and-ga for adding new feature and deprecation rules. Pinging @dibyom for confirmation. This is a field that users can specify. I think we should add a separate field for the new ArrayOrString and implement on the new field

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a change, but it won't have effect on users or introduce breaking changes. And our TEP0076 requires us to change this Value I believe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We came to a conclusion that this won't be breaking the API change policy. However, we definitely are blocked by the design about whether we want to have a brand new struct on this or just rename StringOrArray.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but it doesn't block this PR right, I'm still using StringOrArray. We need to figure out that in Chuang's

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc:@ywluogg, I remember you send email to remind the changes, so we should send emails specifically about cli for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like api mismatch between the pipeline and cli, it should be fixed when we release this change and then bump the pipeline version for cli? Am I correct? @pritidesai

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @tektoncd/cli-maintainers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like api mismatch between the pipeline and cli, it should be fixed when we release this change and then bump the pipeline version for cli? Am I correct? @pritidesai

I think It will be fixed when CLI bumps the pipelines version (which will have these changes) and update their usage/implementation to change the type of the results from string to StringOrArray. The error reported here is coming from:

./pkg/cmd/taskrun/list.go:                              return fmt.Errorf("failed to list TaskRuns from namespace %s: %v", p.Namespace(), err)

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 98.1% 98.3% 0.2
pkg/entrypoint/entrypointer.go 69.7% 84.1% 14.4
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review May 3, 2022 15:51
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 3, 2022
@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-build-tests

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 96.9% 97.4% 0.5
pkg/entrypoint/entrypointer.go 69.7% 84.8% 15.2
pkg/pod/status.go 91.2% 91.1% -0.1
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

var err error
if referencedPipelineTask.IsCustomTask() {
runName = referencedPipelineTask.Run.Name
resultValue, err = findRunResultForParam(referencedPipelineTask.Run, resultRef)
runValue, err = findRunResultForParam(referencedPipelineTask.Run, resultRef)
resultValue = *v1beta1.NewArrayOrString(runValue)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be calling unmarshalling here? Calling NewArrayOrString with runValue here returns a string.

Also, why limiting this to just the custom task?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why limiting this to just the custom task?

So custom task results are still string:

type RunResult struct {
	// Name the given name
	Name string `json:"name"`
	// Value the given value of the result
	Value string `json:"value"`
}

Are we planning on changing the custom task result to string/array? Something coming up ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a great question! We don't support structured results for custom task in this PR. So this is intentionally to return string here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We plan to add support for task and pipeline first, custom task is not discussed and also not explicitly mentioned in the tep (in tep we only mention task and pipeline) but we will discuss later!

https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md#summary

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first use case explicitly talks about custom task - https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md#use-cases Custom task params has use case to consume an array which could be a result of other task and produce a result with an array (a list of hashes/a list of built images).

Thank you @Yongxuanzhang for following up on this 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I have added in our tracking issue

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 96.9% 97.4% 0.5
pkg/entrypoint/entrypointer.go 69.7% 84.8% 15.2
pkg/pod/status.go 91.2% 90.9% -0.3
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

This commit provides support for emitting array results via changing TaskRunResult value from string to ArrayorString and add ResultValue for PipelineResourceResult. Previous to this commit we can only emit string type result.
@pritidesai
Copy link
Member

/test pull-tekton-pipeline-alpha-integration-tests
/test pull-tekton-pipeline-go-coverage

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/param_types.go 96.9% 97.4% 0.5
pkg/entrypoint/entrypointer.go 69.7% 84.8% 15.2
pkg/pod/status.go 91.2% 90.9% -0.3
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 93.8% 94.0% 0.1

@pritidesai
Copy link
Member

@Yongxuanzhang thank you for this 🙏 I have updated the release notes.

@Yongxuanzhang
Copy link
Member Author

@Yongxuanzhang thank you for this 🙏 I have updated the release notes.

Thank you!! ❤️

@pritidesai
Copy link
Member

We have opened an issue to track a type change from string to StringOrArray. This might impact CLI and anyone consuming the result type directly.

This change will be part of the GitHub release notes after a release is created.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 25, 2022
@tekton-robot tekton-robot merged commit d389ed2 into tektoncd:main May 25, 2022
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 27, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes this validation.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 27, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes this validation.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 28, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
Yongxuanzhang added a commit to Yongxuanzhang/pipeline that referenced this pull request Jun 29, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
tekton-robot pushed a commit that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
afrittoli pushed a commit to afrittoli/pipeline that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
tekton-robot pushed a commit that referenced this pull request Jul 1, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
afrittoli pushed a commit to afrittoli/pipeline that referenced this pull request Jul 4, 2022
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
tekton-robot pushed a commit that referenced this pull request Jul 21, 2022
This commit fixes the string result type validation, PR #4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR #4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes the validation for empty result type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants