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

merge VerifyTask and VerifyPipeline into VerifyResource #6724

Merged
merged 1 commit into from
May 29, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 25, 2023

Changes

This commit merges VerifyTask and VerifyPipeline into VerifyResource to reduce duplicate code.

/kind cleanup

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

action required: VerifyTask and VerifyPipeline are now merged into 1 function VerifyResource, please update the usages if upgrade to the new release

@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-none Denotes a PR that doesnt merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels May 25, 2023
@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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 25, 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/trustedresources/verify.go 96.3% 94.9% -1.4

@tekton-robot tekton-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note-none Denotes a PR that doesnt merit a release note. labels May 25, 2023
@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review May 25, 2023 21:50
@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 25, 2023
@Yongxuanzhang Yongxuanzhang changed the title refactor trusted resources to merge VerifyTask and VerifyPipeline merge VerifyTask and VerifyPipeline into VerifyResource May 25, 2023
@Yongxuanzhang
Copy link
Member Author

Yongxuanzhang commented May 25, 2023

/assign @lbernick
/assign @chuangw6
/assign @wlynch
Hi, ptal. Many thanks!

@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/trustedresources/verify.go 96.3% 95.9% -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/trustedresources/verify.go 96.3% 95.9% -0.4

@Yongxuanzhang
Copy link
Member Author

/retest
https://storage.googleapis.com/tekton-prow/pr-logs/pull/tektoncd_pipeline/6724/pull-tekton-pipeline-alpha-integration-tests/1661852264114950144/build-log.txt
might be some issue with resolving the images:

         "step-show-user-2000" exited with code 1 (image: "docker.io/library/ubuntu@sha256:dfd64a3b4296d8c9b62aa3309984f8620b98d87e47492599ee20739e8eb54fbf"); for logs run: kubectl -n arendelle-s9bkm logs show-non-root-steps-run-jghvr-pod -c step-show-user-2000

Comment on lines +97 to +100
tm, signature, err := prepareObjectMeta(v.ObjectMeta)
if err != nil {
return VerificationResult{VerificationResultType: VerificationError, Err: err}
Copy link
Member

Choose a reason for hiding this comment

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

can this block be moved out of the switch statement? I think metav1.Object should have ObjectMeta.

Can you also link the TODO for supporting v1 task/pipeline verification?

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 tried but metav1.Object doesn't have ObjectMeta, it is an interface and has lots of methods.

pkg/trustedresources/verify.go Outdated Show resolved Hide resolved
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 26, 2023
@lbernick
Copy link
Member

/retest https://storage.googleapis.com/tekton-prow/pr-logs/pull/tektoncd_pipeline/6724/pull-tekton-pipeline-alpha-integration-tests/1661852264114950144/build-log.txt might be some issue with resolving the images:

         "step-show-user-2000" exited with code 1 (image: "docker.io/library/ubuntu@sha256:dfd64a3b4296d8c9b62aa3309984f8620b98d87e47492599ee20739e8eb54fbf"); for logs run: kubectl -n arendelle-s9bkm logs show-non-root-steps-run-jghvr-pod -c step-show-user-2000

Can you please open an issue tracking this flake?

@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/trustedresources/verify.go 96.3% 95.9% -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/trustedresources/verify.go 96.3% 95.9% -0.4

@Yongxuanzhang
Copy link
Member Author

Yongxuanzhang commented May 26, 2023

I was thinking whether we should open an issue for this, since it doesn't seem to be an issue from tekton? I will open one just for record

The root bug isn't with Tekton, but knowing that this test is flaky will help us inform if we want to keep it in our test suite and help others know if a test failure they're seeing has been seen elsewhere.

@lbernick
Copy link
Member

sorry Yongxuan I accidentally edited your comment instead of quote replying it!

@Yongxuanzhang
Copy link
Member Author

sorry Yongxuan I accidentally edited your comment instead of quote replying it!

Oh I see, thanks! I'm opening one now.

// VerificationResult is returned with different types for different cases:
// 1) Return VerificationResult with VerificationSkip type, when no policies are found and no-match-policy is set to ignore
// 2) Return VerificationResult with VerificationPass type when verification passed;
// 3) Return VerificationResult with VerificationWarn type, when no matching policies and feature flag "no-match-policy" is "warn", or only Warn mode verification policies fail. Err field is filled with the warning;
// 4) Return VerificationResult with VerificationError type when no policies are found and no-match-policy is set to fail, the resource fails to pass matched enforce verification policy, or there are errors during verification. Err is filled with the err.
// refSource contains the source information of the task.
func VerifyTask(ctx context.Context, taskObj *v1beta1.Task, k8s kubernetes.Interface, refSource *v1beta1.RefSource, verificationpolicies []*v1alpha1.VerificationPolicy) VerificationResult {
Copy link
Member

@JeromeJu JeromeJu May 26, 2023

Choose a reason for hiding this comment

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

Wondering if we should preserve refactored functions like what we did for deprecated fields if that would be better for users? ie. func VerifyTask(..., task, ...) {VerifyResource(..., task, ...)} ?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, 🤔 Let me try that

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

@Yongxuanzhang
Copy link
Member Author

/test pull-tekton-pipeline-go-coverage
network issue

@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/trustedresources/verify.go 96.3% 94.0% -2.3

@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/trustedresources/verify.go 96.3% 94.0% -2.3

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JeromeJu, 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

@JeromeJu
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 29, 2023
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label May 29, 2023
This commit merges VerifyTask and VerifyPipeline into VerifyResource to
reduce duplicate code.

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/trustedresources/verify.go 96.3% 94.0% -2.3

@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/trustedresources/verify.go 96.3% 94.0% -2.3

@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/trustedresources/verify.go 96.3% 94.0% -2.3

@JeromeJu
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 29, 2023
@tekton-robot tekton-robot merged commit 87094b9 into tektoncd:main May 29, 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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. 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.

6 participants