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-0091] return VerificationResult from GetPipeline #6736

Merged
merged 1 commit into from
May 31, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 29, 2023

Changes

This commits updates GetPipeline to return
VerificationResult. VerificationResult is returned by VerifyResource in remote resolution.

4th PR of #6665

This PR is similar to #6691

/kind feature

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com

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

 GetPipeline is updated to return VerificationResult, VerificationResult is the from trusted resources to indicate the result of the verification

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels May 29, 2023
@tekton-robot tekton-robot requested review from dibyom and imjasonh May 29, 2023 17:34
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 29, 2023
@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review May 29, 2023 17:34
@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 29, 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/pipelinerun/pipelinerun.go 90.4% 89.9% -0.4
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 89.9% -0.4
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.4

@Yongxuanzhang
Copy link
Member Author

/assign @lbernick
/assign @chuangw6

@@ -423,6 +423,12 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get
}
}

if pipelineMeta.VerificationResult != nil && pipelineMeta.VerificationResult.VerificationResultType == trustedresources.VerificationError {
Copy link
Member

Choose a reason for hiding this comment

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

should we remove the case errors.Is(err, trustedresources.ErrResourceVerificationFailed)? Also, is there a test for marking the PipelineRun failed when GetPipelineData returns a verificationResult w/ type VerificationError?

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 to keep the pipelinerun.go behave like before, we have an error check above

	case errors.Is(err, trustedresources.ErrResourceVerificationFailed):
		message := fmt.Sprintf("PipelineRun %s/%s referred pipeline failed signature verification", pr.Namespace, pr.Name)
		pr.Status.MarkFailed(ReasonResourceVerificationFailed, message)
		return controller.NewPermanentError(err)

I just realized that I should remove that error check since we now rely on the VerificationResult.

For the test, yes, we have reconciler tests here:

func TestReconcile_verifyResolvedPipeline_Error(t *testing.T) {

This can make sure if GetPipelineData returns a verificationResult w/ type VerificationError, the pipelinerun is marked as failed.

I will openother PRs to update taskrun and pipelinerun code to check the VerificationResult and update conditions.

@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/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.4

@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 May 30, 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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.4

Copy link
Member

@chuangw6 chuangw6 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 @Yongxuanzhang !

Out of scope of this PR:
I see a pattern existing in some functions i.e. readRuntimeObjectAsPipeline, resolvePipeline and GetPipeline that all need return two of or all of the three results Pipeline, refsource and VerificationResult.

And we are just expanding the number of return values as needed i.e. I added refSource in previous project, and you introduced VerificationResult. This will become hard to manage and understand for others if we want to introduce more meta fields in future.

A potential cleanup is to pass those values through a single struct and we already have a meta struct that we can leverage

Example:

type ResolvedPipeline {
   pipeline *v1beta1.Pipeline
   resolvedMeta *resolution.ResolvedObjectMeta
}

Same for task level

type ResolvedTask {
   task *v1beta1.Task
   resolvedMeta *resolution.ResolvedObjectMeta
}

WDYT?

pkg/reconciler/pipelinerun/resources/pipelineref_test.go Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/resources/pipelineref_test.go Outdated Show resolved Hide resolved
Comment on lines +573 to 580
expected runtime.Object
expectedRefSource *v1beta1.RefSource
expectedVerificationResult *trustedresources.VerificationResult
}{{
Copy link
Member

Choose a reason for hiding this comment

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

https://google.github.io/styleguide/go/decisions#got-before-want

Suggested change
expected runtime.Object
expectedRefSource *v1beta1.RefSource
expectedVerificationResult *trustedresources.VerificationResult
}{{
wantPipeline runtime.Object
wantRefSource *v1beta1.RefSource
wantExpectedVerificationResult *trustedresources.VerificationResult
}{{

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 will update this in another PR for all trusted resources tests

pkg/reconciler/pipelinerun/resources/pipelineref_test.go Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/resources/pipelineref_test.go Outdated Show resolved Hide resolved
@Yongxuanzhang
Copy link
Member Author

Thank you @Yongxuanzhang !

Out of scope of this PR: I see a pattern existing in some functions i.e. readRuntimeObjectAsPipeline, resolvePipeline and GetPipeline that all need return two of or all of the three results Pipeline, refsource and VerificationResult.

And we are just expanding the number of return values as needed i.e. I added refSource in previous project, and you introduced VerificationResult. This will become hard to manage and understand for others if we want to introduce more meta fields in future.

A potential cleanup is to pass those values through a single struct and we already have a meta struct that we can leverage

Example:

type ResolvedPipeline {
   pipeline *v1beta1.Pipeline
   resolvedMeta *resolution.ResolvedObjectMeta
}

Same for task level

type ResolvedTask {
   task *v1beta1.Task
   resolvedMeta *resolution.ResolvedObjectMeta
}

WDYT?

I had the same thought, probably open a PR later when I finish all the work

@Yongxuanzhang Yongxuanzhang requested a review from chuangw6 May 31, 2023 15:59
@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/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.4

This commits updates GetPipeline to return
VerificationResult. VerificationResult is returned by VerifyResource in
remote resolution.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
@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/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.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/reconciler/pipelinerun/pipelinerun.go 90.4% 90.4% 0.0
pkg/reconciler/pipelinerun/resources/pipelineref.go 92.3% 93.8% 1.4

@chuangw6
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 31, 2023
@tekton-robot tekton-robot merged commit 8d1a903 into tektoncd:main May 31, 2023
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/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.

4 participants