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-0118: Update TaskRun Validation for Matrix Include Params #6418

Merged

Conversation

EmmaMunley
Copy link
Contributor

@EmmaMunley EmmaMunley commented Mar 21, 2023

Changes

This PR updates TaskRun validation to also validate Matrix Include Params. With this change, we validate that all parameters declared in the TaskSpec are present in the TaskRun. It also validates that all parameters have values, parameter types match the specified type and object params have all the keys required.

Also added testing to bring test coverage to 100%.

Note: Matrix Include is still in preview mode.

/kind feature

Submitter Checklist

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

  • [N/A] Has Docs included if any changes are user facing
  • 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
  • [N/A] Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • [N/A] Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 21, 2023
@EmmaMunley
Copy link
Contributor Author

/Assign @jerop @pritidesai
/Hold until #6407 merges
cc: @lbernick

This is branched off of #6407 to avoid merge conflicts.
Please only review these 2 files (the rest are part of #6407)
validate_taskrun.go
validate_taskrun_test.go

@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 Mar 21, 2023
@EmmaMunley EmmaMunley mentioned this pull request Mar 21, 2023
7 tasks
@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/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 96.0% -0.0
pkg/reconciler/taskrun/validate_taskrun.go 97.8% 96.9% -0.9

@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/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 96.0% -0.0
pkg/reconciler/taskrun/validate_taskrun.go 97.8% 96.9% -0.9

@EmmaMunley
Copy link
Contributor Author

Also not sure why the code coverage went down. I've compared the code coverage with the last PR to have file changes: #6150 and it looks like it has the exact same code coverage, except for whatever reason it is now highlighting in red this section of code (which is unchanged in this PR)

      if _, ok := neededParamsTypes[param.Name]; !ok {
                        // Ignore any missing params - this happens when extra params were
                        // passed to the task that aren't being used.
                        continue
                }

Screenshot 2023-03-22 at 12 08 55 PM

Screenshot 2023-03-22 at 12 09 19 PM

@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/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 96.0% -0.0
pkg/reconciler/taskrun/validate_taskrun.go 97.8% 96.9% -0.9

@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/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.0% 96.0% -0.0
pkg/reconciler/taskrun/validate_taskrun.go 97.8% 96.9% -0.9

@EmmaMunley EmmaMunley force-pushed the validate-taskrun-matrix-include branch from 6605a41 to dc39b2b Compare March 22, 2023 21:16
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 22, 2023
@EmmaMunley EmmaMunley force-pushed the validate-taskrun-matrix-include branch 2 times, most recently from bf005e5 to a866dc6 Compare March 22, 2023 21:39
@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/reconciler/taskrun/validate_taskrun.go 97.8% 98.4% 0.7

@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/reconciler/taskrun/validate_taskrun.go 97.8% 98.4% 0.7

@EmmaMunley
Copy link
Contributor Author

Also not sure why the code coverage went down. I've compared the code coverage with the last PR to have file changes: #6150 and it looks like it has the exact same code coverage, except for whatever reason it is now highlighting in red this section of code (which is unchanged in this PR)

      if _, ok := neededParamsTypes[param.Name]; !ok {
                        // Ignore any missing params - this happens when extra params were
                        // passed to the task that aren't being used.
                        continue
                }

Screenshot 2023-03-22 at 12 08 55 PM

Screenshot 2023-03-22 at 12 09 19 PM

Added additional testing

@EmmaMunley EmmaMunley force-pushed the validate-taskrun-matrix-include branch from a866dc6 to 0b29a67 Compare March 22, 2023 21:57
@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/reconciler/taskrun/validate_taskrun.go 97.8% 98.4% 0.7

@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/reconciler/taskrun/validate_taskrun.go 97.8% 98.4% 0.7

pkg/reconciler/taskrun/validate_taskrun.go Outdated Show resolved Hide resolved
pkg/reconciler/taskrun/validate_taskrun.go Outdated Show resolved Hide resolved
pkg/reconciler/taskrun/validate_taskrun.go Show resolved Hide resolved
pkg/reconciler/taskrun/validate_taskrun_test.go Outdated Show resolved Hide resolved
pkg/reconciler/taskrun/validate_taskrun_test.go Outdated Show resolved Hide resolved
@lbernick lbernick self-assigned this Mar 23, 2023
@EmmaMunley EmmaMunley force-pushed the validate-taskrun-matrix-include branch from 750641e to afe0a98 Compare March 24, 2023 02:14
@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 Mar 24, 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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

@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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

@EmmaMunley EmmaMunley requested review from lbernick and jerop and removed request for lbernick and jerop March 24, 2023 13:35
Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

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

Thanks Emma! Looks great!

pkg/reconciler/taskrun/validate_taskrun_test.go Outdated Show resolved Hide resolved
Value: *v1beta1.NewStructuredValues("array", "param"),
}},
matrix: &v1beta1.Matrix{},
wantErr: "invalid input params for task : param types don't match the user-specified type: [foo]",
Copy link
Member

Choose a reason for hiding this comment

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

Suggest including more info in this error message comparing the type received to the type specified; see #6365 (comment) for more detail on why.
Although this might be better in a separate PR

pkg/reconciler/taskrun/validate_taskrun_test.go Outdated Show resolved Hide resolved
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lbernick

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 Mar 24, 2023
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.

/unhold

@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 Mar 27, 2023
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, lbernick

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

This commit updates TaskRun validation to also validate Matrix Include Params. With this change, we validate that all parameters declared in the TaskSpec are present in the TaskRun. It also validates that all parameters have values, parameter types match the specified type and object params have all the keys required.
Note: Matrix Include is still in preview mode.
@EmmaMunley EmmaMunley force-pushed the validate-taskrun-matrix-include branch from afe0a98 to d1f8e96 Compare March 27, 2023 14:27
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 27, 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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

@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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

@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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

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.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2023
@jerop
Copy link
Member

jerop commented Mar 27, 2023

/test pull-tekton-pipeline-go-coverage

@tekton-robot tekton-robot merged commit 8638170 into tektoncd:main Mar 27, 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/reconciler/taskrun/validate_taskrun.go 97.8% 100.0% 2.2

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-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants