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

Validate additionalTags #3177

Merged
merged 1 commit into from Feb 9, 2022

Conversation

jonathanbeber
Copy link
Contributor

@jonathanbeber jonathanbeber commented Feb 8, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

As described in #3102, tags keys currently can be empty or do not
respect other AWS rules for tagging, resulting in errors during
resources provisioning.

This commit adds validation to the tags in the webhook, for all the
resource where additionalTags is present, during creation and update.

Validation is done in the webhook instead of OpenAPI schema due to
limitations in the current additionalTags field type, as better
described in #3102.

Which issue(s) this PR fixes:
Part of #3102

Special notes for your reviewer:

Checklist:

  • squashed commits
  • adds unit tests
  • adds or updates e2e tests

Release note:

additionalTags are now validated to comply with AWS API requirements

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Feb 8, 2022
@k8s-ci-robot
Copy link
Contributor

@jonathanbeber: This issue is currently awaiting triage.

If CAPA/CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 8, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @jonathanbeber. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 8, 2022
@sedefsavas
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 8, 2022
@sedefsavas sedefsavas added this to the v1.4.0 milestone Feb 8, 2022
@sedefsavas sedefsavas added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority labels Feb 8, 2022
@sedefsavas
Copy link
Contributor

LGTM.

One comment: is it enough to add just a single test as tags_test.go, given that same tag validation is used by all webhooks?

@richardcase
Copy link
Member

Thanks @jonathanbeber

We also use tags in a number of other resource kinds:

Do you think it would be possible to add similar validation checks to the webhooks for these? This would be great as it would give us consistent tag validation across all our resource kinds 🎉

@jonathanbeber
Copy link
Contributor Author

Thank you very much for your quick review and feedback.

LGTM.

One comment: is it enough to add just a single test as tags_test.go, given that same tag validation is used by all webhooks?

Maybe I didn't follow completely this one, @sedefsavas. You mean like testing in just one of the webhooks? That would leave us in a situation where a line like this one is removed and the tests wouldn't break.


@richardcase sure thing, I'm not sure how I missed those 🤦‍♂️ but for sure I will work in adding them too.

As described in kubernetes-sigs#3102, tags keys currently can be empty or do not
respect other AWS rules for tagging, resulting in errors during
resources provisioning.

This commit adds validation to the tags in the webhook, for all the
resource where `additionalTags` is present, during creation and update.

Validation is done in the webhook instead of OpenAPI schema due to
limitations in the current `additionalTags` field type, as better
described in kubernetes-sigs#3102.
@k8s-ci-robot k8s-ci-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 Feb 9, 2022
@jonathanbeber
Copy link
Contributor Author

@richardcase I added the validation for other resources. I realised I ignored them because they were part of other packages, thanks for pointing it out.

For some of the resources I had to add new test cases as the validation was not being tested.

@sedefsavas
Copy link
Contributor

/lgtm

/assign @richardcase

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 9, 2022
@richardcase
Copy link
Member

Thanks for making those changes @jonathanbeber .

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: richardcase

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit 8845729 into kubernetes-sigs:main Feb 9, 2022
@k8s-ci-robot k8s-ci-robot modified the milestones: v1.4.0, v1.x Feb 9, 2022
@jonathanbeber jonathanbeber deleted the validatetags branch February 9, 2022 18:10
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants