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-0107: propagate results to embedded task spec #7100

Merged

Conversation

chengjoey
Copy link
Member

@chengjoey chengjoey commented Sep 11, 2023

Changes

  1. add container type substitution expresions to pipeline task result reference
  2. propagate results to embedded task spec

Part of work on issue #7086 , passing-results

Submitter Checklist

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

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Results are propagated in embedded specifications without mutations.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 11, 2023
@chengjoey
Copy link
Member Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 11, 2023
@chengjoey
Copy link
Member Author

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2023
@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/v1/container_types.go 31.2% 30.2% -1.0
pkg/apis/pipeline/v1/pipeline_validation.go 99.1% 98.6% -0.5
pkg/apis/pipeline/v1/resultref.go 98.2% 98.3% 0.1
pkg/reconciler/pipelinerun/pipelinerun.go 92.7% 92.7% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.1% 97.7% -0.4

@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from 1155c16 to 9f28178 Compare September 11, 2023 08:50
@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/v1/container_types.go 31.2% 30.2% -1.0
pkg/apis/pipeline/v1/pipeline_validation.go 99.1% 98.6% -0.5
pkg/apis/pipeline/v1/resultref.go 98.2% 98.3% 0.1
pkg/reconciler/pipelinerun/pipelinerun.go 92.7% 92.7% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.1% 97.7% -0.4

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 30.2% -1.0
pkg/apis/pipeline/v1/pipeline_validation.go 99.1% 98.6% -0.5
pkg/apis/pipeline/v1/resultref.go 98.2% 98.3% 0.1
pkg/reconciler/pipelinerun/pipelinerun.go 92.7% 92.7% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.1% 97.7% -0.4

@chitrangpatel
Copy link
Contributor

/assign

docs/pipelineruns.md Outdated Show resolved Hide resolved
docs/pipelineruns.md Outdated Show resolved Hide resolved
docs/pipelineruns.md Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/pipeline_validation.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1/container_types.go Outdated Show resolved Hide resolved
@jerop jerop added this to the Pipelines v0.53 milestone Sep 20, 2023
@jerop jerop added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 21, 2023
@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from 9f28178 to 39bfe9f Compare September 21, 2023 14:20
@chengjoey
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 21, 2023
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 30.2% -1.0
pkg/apis/pipeline/v1/pipeline_validation.go 99.1% 98.6% -0.5
pkg/reconciler/pipelinerun/pipelinerun.go 92.7% 92.7% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.1% 97.7% -0.4

@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/v1/container_types.go 31.2% 30.2% -1.0
pkg/apis/pipeline/v1/pipeline_validation.go 99.1% 98.6% -0.5
pkg/reconciler/pipelinerun/pipelinerun.go 92.7% 92.7% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.1% 97.7% -0.4

Metadata:
...
Spec:
Task Spec:
Copy link
Member

Choose a reason for hiding this comment

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

nit: the yaml seems to need some formatting: apiVersion, taskSpec and etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

done~

stringReplacements[fmt.Sprintf("tasks.%s.results.%s", taskName, res.Name)] = res.Value.StringVal
case v1.ResultsTypeArray:
arrayReplacements[fmt.Sprintf("tasks.%s.results.%s", taskName, res.Name)] = res.Value.ArrayVal
case v1.ResultsTypeObject:
Copy link
Member

Choose a reason for hiding this comment

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

Wondering what is propagation for ResultsTypeObject?

Copy link
Member Author

Choose a reason for hiding this comment

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

I put the ResultsTypeObject into stringReplacements

In the following way:

for k, v := range res.Value.ObjectVal {
	stringReplacements[fmt.Sprintf("tasks.%s.results.%s.%s", taskName, res.Name, k)] = v
}

@@ -497,6 +497,21 @@ func (pt *PipelineTask) extractAllParams() Params {
return allParams
}

func (pt *PipelineTask) GetVarSubstitutionExpressions() ([]string, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Shall we add some more docString for this since it is an exported func?

Copy link
Member Author

Choose a reason for hiding this comment

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

added

GetVarSubstitutionExpressions extract all values between the parameters "$(" and ")" of steps and sidecars

var allExpressions []string
if pt.TaskSpec != nil {
for _, step := range pt.TaskSpec.Steps {
stepExpressions, _ := step.GetVarSubstitutionExpressions()
Copy link
Member

Choose a reason for hiding this comment

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

Could you help me to understand why is the bool return value needed here? It seems that this is implying whether the expressions is of len 0, but the actual returned values are unused.

Copy link
Member Author

Choose a reason for hiding this comment

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

the returned bool value is indeed not used. I modified the function and only returned expressions.

@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from 39bfe9f to 07e1121 Compare October 7, 2023 02:59
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 7, 2023
@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from 98f857f to fa87932 Compare October 20, 2023 06:41
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 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/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from fa87932 to 7cb7b9c Compare October 20, 2023 07:25
@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/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch 2 times, most recently from e80923b to 2539118 Compare October 20, 2023 08:25
@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/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

… reference

2. propagate results to embedded task spec
Part of work on issue tektoncd#7086

Signed-off-by: chengjoey <[email protected]>
@chengjoey chengjoey force-pushed the feat/TEP-107-results-propagation branch from 2539118 to 9be1652 Compare October 20, 2023 14:51
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 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/v1/container_types.go 31.2% 62.5% 31.2
pkg/apis/pipeline/v1/pipeline_validation.go 99.2% 99.2% 0.0
pkg/reconciler/pipelinerun/pipelinerun.go 92.4% 92.4% 0.0
pkg/reconciler/pipelinerun/resources/apply.go 98.3% 98.4% 0.1

@chengjoey
Copy link
Member Author

@chengjoey I can help. It seems like your test is fighting the feature flags. You need to set "enable-api-fields": "alpha or beta" for this to work. My guess is that's because you are using object results. Screenshot 2023-10-19 at 3 02 41 PM

Some of the other e2e tests that use enable-api-fields might help here.

Thanks! @chitrangpatel , it worked

@chengjoey chengjoey requested a review from jerop October 20, 2023 15:34
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

thank you @chengjoey 🎉

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2023
@chitrangpatel
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 20, 2023
@tekton-robot tekton-robot merged commit 5066b40 into tektoncd:main Oct 20, 2023
12 checks passed
chitrangpatel added a commit to chitrangpatel/pipeline that referenced this pull request Oct 20, 2023
PR tektoncd#7100 introduced a flaky
test. When comparing the pipelineRuns and TaskRuns, the results were not
sorted. As a result, `cmp.Diff` throws an error sometimes when the order
does not match.

This PR sorts the TaskRunResults by providing a sort function to
`cmp.Diff`. After the fix, running this 20 times consecutively,  no flakes were found.
tekton-robot pushed a commit that referenced this pull request Oct 21, 2023
PR #7100 introduced a flaky
test. When comparing the pipelineRuns and TaskRuns, the results were not
sorted. As a result, `cmp.Diff` throws an error sometimes when the order
does not match.

This PR sorts the TaskRunResults by providing a sort function to
`cmp.Diff`. After the fix, running this 20 times consecutively,  no flakes were found.
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. kind/feature Categorizes issue or PR as related to a new feature. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants