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

[PodSecurity] Expand unit test coverage and fix error cases #106017

Merged
merged 4 commits into from Nov 3, 2021

Conversation

tallclair
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

  1. Add unit test for ValidatePod, exercising all possible response paths.
  2. Reuse the test fixtures to refactor (and expand coverage) of ValidatePodController tests
  3. Tests revealed that validation errors on pod controllers reject the request, even though controller validation is never enforcing. Errors validating controller resources now always return an allowed response.
  4. Always set the error audit annotation when an error prevented normal policy evaluation.

Special notes for your reviewer:

This PR has overlap with several in-flight PRs, so conflicts will need to be resolved depending on which merges first.

Does this PR introduce a user-facing change?

(PodSecurity admission) errors validating workload resources (deployment, replicaset, etc.) no longer block admission.

/sig auth
/assign @liggitt
/milestone v1.23

@tallclair tallclair added this to In Review in SIG-Auth: PodSecurity via automation Oct 30, 2021
@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. labels Oct 30, 2021
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/auth Categorizes an issue or PR as relevant to SIG Auth. labels Oct 30, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 30, 2021
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 30, 2021
@k8s-ci-robot
Copy link
Contributor

@tallclair: This issue is currently awaiting triage.

If a SIG or subproject 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-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 30, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tallclair

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 Oct 30, 2021
@enj enj added this to Needs Triage in SIG Auth Old Nov 1, 2021
@ritazh ritazh moved this from Needs Triage to In Review in SIG Auth Old Nov 1, 2021
Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

a few nits, lgtm overall

@liggitt liggitt added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2021
Copy link
Member Author

@tallclair tallclair left a comment

Choose a reason for hiding this comment

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

Feedback addressed. Also refactored error response helpers a bit (including moving to admission/response.go)

@tallclair
Copy link
Member Author

This will need to be rebased once #105898 merges. Feel free to hold off on further review until I've had a chance to resolve that.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2021
@tallclair tallclair force-pushed the unit-test branch 2 times, most recently from 0005929 to 3897ea8 Compare November 2, 2021 20:55
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2021
@tallclair
Copy link
Member Author

Rebased, and added additional coverage for error & exemption metrics. Also added a shared response for the privileged short-circuit case that includes the enforce-policy audit annotation, and refactored the shared responses a bit.

@liggitt
Copy link
Member

liggitt commented Nov 2, 2021

/retest
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2021
@liggitt liggitt moved this from In Review to Done (1.23, Beta) in SIG-Auth: PodSecurity Nov 2, 2021
@liggitt
Copy link
Member

liggitt commented Nov 2, 2021

sigh... one last rebase needed

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2021
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 2, 2021
@tallclair
Copy link
Member Author

rebased

@liggitt
Copy link
Member

liggitt commented Nov 2, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2021
@k8s-ci-robot k8s-ci-robot merged commit e48cb8a into kubernetes:master Nov 3, 2021
SIG Auth Old automation moved this from In Review to Closed / Done Nov 3, 2021
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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Archived in project
SIG-Auth: PodSecurity
Done (1.23, Beta)
SIG Auth Old
Closed / Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants