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

can't load security-profiles-operator as dependancy of another operator #2746

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

Billy99
Copy link
Contributor

@Billy99 Billy99 commented Feb 28, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

For #2699
When loaded through OperatorHub as a dependency of another operator, security-profiles-operator is loaded in the namespace of the other operator. When this happens, any created SelinuxProfile stays in the Pending State.

It appears that the function getDS() is searching for the DaemonSet with a label of "spod". However, the r.client.List() call is returning all DaemonSets in the Namespace and bailing because it found more than one.

This commit changes the logic to call Get() instead of GetList().

While trying to verify the above, ran into issues with the move of SelinuxProfile from namespace scoped to cluster scoped (#2745). Recently SelinuxProfile was moved from Namespace scoped to cluster scoped. Some of the code was still using the Namespace as part of the generation of the "Usage" string. The Namespace was blank, so the usage string just ended in an "_", something like "policyName_.process". However, workloadannotator was using the application pods namespace and the code to strip the "_namspace.process" off the usage string to get the actual profile name was failing. So just removed all the logic was appending "_namespace" to the profile name in the Usage since namespace is no longer used.

Which issue(s) this PR fixes:

Fixes #2699
Fixes #2745

Does this PR have test?

No, but the linked issues describe how to reproduce.

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The Usage should no longer have an "_" after the profile name.


@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 28, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @Billy99!

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 Feb 28, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Billy99. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 28, 2025
@saschagrunert
Copy link
Member

/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 28, 2025
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 28, 2025
@saschagrunert
Copy link
Member

/lgtm cancel

CI is not happy:

internal/pkg/manager/nodestatus/nodestatus.go:268:3: return with no blank line before (nlreturn)
		return nil, fmt.Errorf("cannot Get DS: %w", err)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2025
@Billy99 Billy99 force-pushed the billy99-getds branch 3 times, most recently from 514e07b to 1a64f22 Compare February 28, 2025 14:37
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.

Project coverage is 23.31%. Comparing base (11d77f4) to head (03083bb).
Report is 743 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2746       +/-   ##
===========================================
- Coverage   45.50%   23.31%   -22.19%     
===========================================
  Files          79      117       +38     
  Lines        7782    19711    +11929     
===========================================
+ Hits         3541     4596     +1055     
- Misses       4099    14897    +10798     
- Partials      142      218       +76     

@saschagrunert
Copy link
Member

@Billy99 do you mind fixing the commit message?

@Billy99
Copy link
Contributor Author

Billy99 commented Mar 3, 2025

@Billy99 do you mind fixing the commit message?

Sure, what would you like fixed?

@saschagrunert
Copy link
Member

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • 5d27dc8 can't load security-profiles-operator as dependancy of another operator
  • 1a64f22 after moving to cluster scoped, namesapce still used

@Billy99 👆

@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Mar 3, 2025
@saschagrunert saschagrunert added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 3, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Billy99, ccojocar, saschagrunert

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:
  • OWNERS [ccojocar,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Billy99 added 2 commits March 3, 2025 09:56
When loaded through OperatorHub as a dependency of another operator,
security-profiles-operator is loaded in the namespace of the other operator.
When this happens, any created SelinuxProfile stays in the Pending State.

It appears that the function getDS() is searching for the DaemonSet with
a label of "spod". However, the r.client.List() call is returning all
DaemonSets in the Namespace and bailing because it found more than one.

This commit changes the logic to call Get() instead of GetList().

See: 2699

Signed-off-by: Billy McFall <[email protected]>
Recently SelinuxProfile was moved from Namespace scoped to Cluster
scoped. Some of the code was still using the Namespace as part of the
generation of the  "Usage" string. The Namespace was blank, so the usage
string just ended in an "_", something like "policyName_.process".
However, workloadannotator was using the application pods namespace and
the code strip the "_namspace.process" off the usage string to get the
actual profile name was failing. So just removed all the logic was
append "_namespace" to the profile name in the usage.

See: 2745

Signed-off-by: Billy McFall <[email protected]>
@Billy99
Copy link
Contributor Author

Billy99 commented Mar 3, 2025

@saschagrunert On Friday e2e-seccomp-profile was failing, but today e2e-ubuntu is failing. Is there something with my code I need to be investigating or is this typical for a PR merging?

@saschagrunert
Copy link
Member

@Billy99 this looks like a flake, let me restart the test

@k8s-ci-robot k8s-ci-robot merged commit d867b56 into kubernetes-sigs:main Mar 3, 2025
28 checks passed
@Billy99 Billy99 deleted the billy99-getds branch March 3, 2025 19:14
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. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
5 participants