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

Add Support for Selinux Profile Binding #854

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

Vincent056
Copy link
Contributor

/kind feature

What this PR does / why we need it:

This change updates SPO binding webhook to support SelinuxProfile binding and updates ProfileBinding CRD to allow SelinuxProfile as a profile reference.

Does this PR have test?

Yes

Does this PR introduce a user-facing change?

Yes

Add the ability to use SelinuxProfile when creating profilebinding objects.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 22, 2022
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 22, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Vincent056 / name: Vincent Shen (5e3b442)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 22, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @Vincent056!

It looks like this is your first PR to kubernetes-sigs/security-profiles-operator 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/security-profiles-operator has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 22, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @Vincent056. 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 Mar 22, 2022
@k8s-ci-robot k8s-ci-robot requested review from cmurphy and JAORMX March 22, 2022 08:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 22, 2022
@JAORMX
Copy link
Contributor

JAORMX commented Mar 22, 2022

/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 Mar 22, 2022
@JAORMX
Copy link
Contributor

JAORMX commented Mar 22, 2022

Hey @Vincent056 glad to see you're starting to contribute here! Seems the PR has a merge conflict, so you'd need to fix that first.

@Vincent056
Copy link
Contributor Author

Hey @Vincent056 glad to see you're starting to contribute here! Seems the PR has a merge conflict, so you'd need to fix that first.

I also need to update the workloadannotator controller to handle the finalizer for SelinuxProfile, excited to work on this!

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. do-not-merge/contains-merge-commits and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 24, 2022
@Vincent056 Vincent056 force-pushed the selinux branch 3 times, most recently from d50a2e6 to 2e00f70 Compare March 24, 2022 10:29
@jhrozek
Copy link
Contributor

jhrozek commented Mar 24, 2022

You'll want to fix the verify issues, see e.g. https://github.com/kubernetes-sigs/security-profiles-operator/runs/5674912566?check_suite_focus=true
locally you can run make verify, warning, your tree must be clean locally (so, no untracked files).
Many issues can be fixed by running golangci-lint run --fix, sometimes repeatedly, sometimes with a little manual help (I found that it screws up imports when sorting them..).

@jhrozek
Copy link
Contributor

jhrozek commented Mar 24, 2022

Not sure why the patch shows up twice in GH, have you rebased atop origin/main (keep in mind that SPO doesn't use master anymore, but main...)

@Vincent056
Copy link
Contributor Author

The OLM test is failing, I think you need to run make bundle and then commit the results:

+++ b/bundle/manifests/security-profiles-operator.x-k8s.io_rawselinuxprofiles.yaml
@@ -49,6 +49,10 @@ spec:
           status:
             description: SelinuxProfileStatus defines the observed state of SelinuxProfile.
             properties:
+              activeWorkloads:
+                items:
+                  type: string
+                type: array
               conditions:
                 description: Conditions of the resource.
                 items:

Got

FATA[0000] failed to read config: error unmarshalling project configuration: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field Config.layout of type string 

And did not realize I was using the old operator-sdk lol

Copy link
Contributor

@jhrozek jhrozek 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, I left some comments inline, I think the PR is getting close!

errSeccomp := r.client.List(ctx, seccompProfiles, client.MatchingFields{linkedPodsKey: podID})
errSelinux := r.client.List(ctx, selinuxProfiles, client.MatchingFields{linkedPodsKey: podID})

if errSeccomp != nil && errSelinux != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

did you want to use '||' instead of '&&' here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was intended, we don't want to continue if we can not list either seccomp profiles or selinux profiles

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, either. So there should be an OR, right? Otherwise if errSeccomp is non-nil and errSelinux is nil, the condition doesn't match and we continue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's why I have separate check for errSeccomp and errSelinux after that

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I get it now, but in case only one of the lists has an error, we don't reconcile again and just ignore the error. Is that OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh I see, I guess I should use or here instead.

@jhrozek
Copy link
Contributor

jhrozek commented Apr 1, 2022

The OLM test is failing, I think you need to run make bundle and then commit the results:

+++ b/bundle/manifests/security-profiles-operator.x-k8s.io_rawselinuxprofiles.yaml
@@ -49,6 +49,10 @@ spec:
           status:
             description: SelinuxProfileStatus defines the observed state of SelinuxProfile.
             properties:
+              activeWorkloads:
+                items:
+                  type: string
+                type: array
               conditions:
                 description: Conditions of the resource.
                 items:

Got

FATA[0000] failed to read config: error unmarshalling project configuration: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field Config.layout of type string 

And did not realize I was using the old operator-sdk lol

The OLM test is failing, I think you need to run make bundle and then commit the results:

+++ b/bundle/manifests/security-profiles-operator.x-k8s.io_rawselinuxprofiles.yaml
@@ -49,6 +49,10 @@ spec:
           status:
             description: SelinuxProfileStatus defines the observed state of SelinuxProfile.
             properties:
+              activeWorkloads:
+                items:
+                  type: string
+                type: array
               conditions:
                 description: Conditions of the resource.
                 items:

Got

FATA[0000] failed to read config: error unmarshalling project configuration: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field Config.layout of type string 

And did not realize I was using the old operator-sdk lol

SPO should be using operator-sdk from ./build not the system-wide one or the one in GOPATH, if it is, we might have a bug somewhere in the Makefiles where we don't call the right binary.

@Vincent056 Vincent056 force-pushed the selinux branch 2 times, most recently from 094ae59 to d9646cf Compare April 1, 2022 11:43
@Vincent056
Copy link
Contributor Author

/retest

@jhrozek
Copy link
Contributor

jhrozek commented Apr 1, 2022

Looks good except the one comment about the AND vs OR. In the meantime, @saschagrunert can you please allow GH actions to be ran? I can't seem to be able to do it

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2022
@Vincent056 Vincent056 force-pushed the selinux branch 4 times, most recently from afbaa43 to d1bdaca Compare April 4, 2022 19:59
@Vincent056
Copy link
Contributor Author

Sorry to bug again, wondering if anyone could approve the GH action workflows to run?, @saschagrunert @jhrozek Thanks

@Vincent056 Vincent056 force-pushed the selinux branch 2 times, most recently from e79bde3 to 5623351 Compare April 5, 2022 08:53
This change updates binding webhook to support SelinuxProfile binding and updates ProfileBinding to allow SelinuxProfile as profile reference.
@saschagrunert
Copy link
Member

/retest

Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

/lgtm
awesome work, thank you for the patience during the review!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhrozek, Vincent056

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 Apr 6, 2022
@k8s-ci-robot k8s-ci-robot merged commit f4a6c6a into kubernetes-sigs:main Apr 6, 2022
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/feature Categorizes issue or PR as related to a new feature. 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. 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.

6 participants