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] add KMS field #5891

Merged
merged 1 commit into from
Jan 5, 2023
Merged

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Dec 19, 2022

Changes

This commit add KMS into v1alpha1.VerificationPolicy and validation. KMS field is used to configure the KMS path and can be used to resolve keys stored in key management system by cloud providers. Before this commit we only support loading keys from file or raw data.

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

Release Notes

Add KMS filed into v1alpha1.VerificationPolicy

@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 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. kind/feature Categorizes issue or PR as related to a new feature. labels Dec 19, 2022
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 19, 2022
@Yongxuanzhang Yongxuanzhang marked this pull request as ready for review December 19, 2022 19:49
@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 Dec 19, 2022
Copy link
Member

@wlynch wlynch 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 Dec 19, 2022
@wlynch
Copy link
Member

wlynch commented Dec 19, 2022

Is there a tracking issue we can associate this with?

@Yongxuanzhang
Copy link
Member Author

Is there a tracking issue we can associate this with?

Yes! I have this issue to track all the PRs and milestones
#5527

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 19, 2022
@Yongxuanzhang Yongxuanzhang requested review from jagathprakash and removed request for pritidesai, bobcatfish, afrittoli and dibyom December 19, 2022 22:03
@Yongxuanzhang
Copy link
Member Author

/retest

@Yongxuanzhang
Copy link
Member Author

/retest

pkg/apis/pipeline/v1alpha1/verificationpolicy_types.go Outdated Show resolved Hide resolved
@@ -95,7 +95,7 @@ func TestVerificationPolicy_Invalid(t *testing.T) {
},
},
},
want: apis.ErrMissingOneOf("key[0].data", "key[0].secretref"),
want: apis.ErrMissingOneOf("data", "kms", "secretref").ViaFieldIndex("key", 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make these test cases less fragile? If the given error changes in the implementation, this test will start failing. Maybe there's a way to untie them such that the test case is less fragile?
For example, what if someone has good reason to change the case from kms to KMS in the implementation -- as written, they now have to change the test code as well -- but this is not a functional change, it's just a change in the error message. Can we test for functional change instead of error message?

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment also applies to the ordering of the error message in index 0. Can we be order-independent such that the test remains valid even if the order of validation changes in the implementation?

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 how we return err for validation in current code base, take this for example:

if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver"))
}
if ref.Bundle != "" {
errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver"))
}
}
if ref.Params != nil {
if ref.Name != "" {
errs = errs.Also(apis.ErrMultipleOneOf("name", "params"))
}
if ref.Bundle != "" {
errs = errs.Also(apis.ErrMultipleOneOf("bundle", "params"))
}
if ref.Resolver == "" {
errs = errs.Also(apis.ErrMissingField("resolver"))
}
errs = errs.Also(ValidateParameters(ctx, ref.Params))

I think we should keep it consistent until we want to change them all

Copy link
Member

Choose a reason for hiding this comment

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

I almost have the opposite take from Bendory-- I often give the feedback he is giving, but here I think it actually makes sense to include the text of the error message rather than apis.ErrMultipleOneOf. The reason is that sometimes these helper functions can lead to confusing error message strings, and you don't really realize what output the user is actually seeing until it's reflected in a test. This does have the downside of brittle tests, though.

Re: consistency, I think the section you're referring to is in non-test code, while the comment David is making is a separate point about brittleness of tests.

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 almost have the opposite take from Bendory-- I often give the feedback he is giving, but here I think it actually makes sense to include the text of the error message rather than apis.ErrMultipleOneOf. The reason is that sometimes these helper functions can lead to confusing error message strings, and you don't really realize what output the user is actually seeing until it's reflected in a test. This does have the downside of brittle tests, though.

Re: consistency, I think the section you're referring to is in non-test code, while the comment David is making is a separate point about brittleness of tests.

Are you suggesting we should avoid using apis.ErrMissingOneOf?. It seems convenient and also used a lot in other validation functions. https://github.com/tektoncd/pipeline/search?q=apis.ErrMissingOneOf

Copy link
Member

Choose a reason for hiding this comment

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

Only in tests. For example, in #5673 I noted a confusing error message "expected exactly one, got both: spec.taskRef.name, spec.taskRef.params, spec.taskRef.resolver", which comes from ErrMultipleOneOf. These helpers are super useful in validation code but in tests IMO it's useful to be able to see the string error message the user encounters so you can check that it's not confusing.

The downside as David pointed out is that if you change "kms" in the code to "KMS", your tests will fail, but not in a way that gives you useful signal about the code. (The comment about indexing here I'm not sure I agree with, since the "0" refers to the index of the problematic field in the test data rather than an artifact of validation ordering.)

I may be going more in depth than is necessary; feel free to use your best judgment here although I'd just note our tests aren't actually that consistent (example)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh I see your point. Thanks!

@Yongxuanzhang Yongxuanzhang force-pushed the add-kms-field branch 2 times, most recently from 72a590b to 634649c Compare December 20, 2022 16:55
@chitrangpatel
Copy link
Member

/test pull-tekton-pipeline-go-coverage-df

@tekton-robot
Copy link
Collaborator

@chitrangpatel: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test pull-tekton-pipeline-go-coverage-df

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 21, 2022
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 3, 2023
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 5, 2023
@@ -95,7 +95,7 @@ func TestVerificationPolicy_Invalid(t *testing.T) {
},
},
},
want: apis.ErrMissingOneOf("key[0].data", "key[0].secretref"),
want: apis.ErrMissingOneOf("data", "kms", "secretref").ViaFieldIndex("key", 0),
Copy link
Member

Choose a reason for hiding this comment

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

I almost have the opposite take from Bendory-- I often give the feedback he is giving, but here I think it actually makes sense to include the text of the error message rather than apis.ErrMultipleOneOf. The reason is that sometimes these helper functions can lead to confusing error message strings, and you don't really realize what output the user is actually seeing until it's reflected in a test. This does have the downside of brittle tests, though.

Re: consistency, I think the section you're referring to is in non-test code, while the comment David is making is a separate point about brittleness of tests.

This commit add KMS into v1alpha1.VerificationPolicy and validation. KMS
field is used to configure the KMS path and can be used to resolve keys
stored in key management system by cloud providers. Before this commit
we only support loading keys from file or raw data.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, wlynch

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

@lbernick
Copy link
Member

lbernick commented Jan 5, 2023

/lgtm

I wouldn't actually use a release note here because you're introducing a field that isn't usable yet, so I'm not sure there's actionable info for users.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 5, 2023
@Yongxuanzhang
Copy link
Member Author

/retest

@tekton-robot tekton-robot merged commit fa2e372 into tektoncd:main Jan 5, 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.

9 participants