Skip to content

OCPBUGS-29729: Updates default security context behavior for catalog source pods #3206

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

Merged

Conversation

perdasilva
Copy link
Collaborator

@perdasilva perdasilva commented Apr 19, 2024

Description of the change:
Before: by default CatalogSource would stamp out pods with the "legacy" security profile
Now: by default CatalogSource stamps out "restricted" security profile pods when in appropriately labeled namespaces and "legacy" otherwise

Motivation for the change:
Helps users be secure-by-default on PSA clusters when deploying in "restricted" namespaces (no change for older clusters)

Architectural changes:

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

bentito added 3 commits April 17, 2024 15:04
This change updates the logic for setting security contexts within the OLM pod reconciler. Now, it differentiates between 'Restricted' and 'Legacy' security contexts more explicitly. The 'Restricted' security context applies default security settings unless overridden, while the 'Legacy' context clears all security settings. When no security context is configured, it defaults to restricted. Additionally, the related tests have been updated to reflect these changes and ensure correct behavior.

Signed-off-by: btofel <[email protected]>
Signed-off-by: btofel <[email protected]>
Signed-off-by: Brett Tofel <[email protected]>
@perdasilva perdasilva changed the title OCPBUS-29729: Updates default security context behavior for catalog source pods [WIP] OCPBUS-29729: Updates default security context behavior for catalog source pods Apr 19, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 19, 2024
@perdasilva perdasilva force-pushed the OCPBUGS-29729-perdasilva branch 7 times, most recently from 50952ce to 9dc398d Compare April 24, 2024 11:25
@perdasilva perdasilva changed the title [WIP] OCPBUS-29729: Updates default security context behavior for catalog source pods OCPBUS-29729: Updates default security context behavior for catalog source pods Apr 24, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2024
@perdasilva perdasilva force-pushed the OCPBUGS-29729-perdasilva branch 8 times, most recently from 2cadc5e to 73c129a Compare April 24, 2024 16:38
@bentito bentito changed the title OCPBUS-29729: Updates default security context behavior for catalog source pods OCPBUGS-29729: Updates default security context behavior for catalog source pods Apr 24, 2024
m1kola
m1kola previously approved these changes Apr 29, 2024
Copy link
Member

@m1kola m1kola left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me, still might be a good idea to get more eyes on it.

Comment on lines 43 to 47
func WithSecurityContextConfig(securityContextConfig v1alpha1.SecurityConfig) PodOptionFunc {
return func(option *PodOption) {
option.SecurityContextConfig = securityContextConfig
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This naming is still something that I think could lead to confusion. This is the default security context config, right?

This name implies that whatever value is here is what will be used. But it isn't until we evaluate the catalog source that we decide what the actual value to use is.

I'm also having trouble understanding why in some cases we use the options ...PodOptionFunc parameter and in others we use the podSecurityConfig v1alpha1.SecurityConfig parameter.

In this case, my suggestions would be:

  • drop the option func (my reasoning is: calling a function that takes this variadic parameter means that passing that parameter is optional, which means we need a default for the default, which just complicates things even more).
  • use defaultPodSecurityConfig as the name of the variables and parameters everywhere, except where we finally decide the securityContext we're going to put into the pod.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see if that's better. I just really wanted to make as few changes as possible XD but you make good points.

@bentito
Copy link
Contributor

bentito commented Apr 29, 2024

This PR is a positive step towards better handling of security contexts in the OLM pod reconciler, making it easier to manage and test security configurations comprehensively. LGTM

joelanford
joelanford previously approved these changes Apr 29, 2024
@joelanford joelanford added this pull request to the merge queue Apr 29, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 29, 2024
@perdasilva perdasilva force-pushed the OCPBUGS-29729-perdasilva branch 4 times, most recently from ee56764 to 66856c2 Compare April 30, 2024 14:31
Signed-off-by: Per Goncalves da Silva <[email protected]>
@perdasilva perdasilva force-pushed the OCPBUGS-29729-perdasilva branch from 66856c2 to 27f9246 Compare April 30, 2024 14:33
@bentito
Copy link
Contributor

bentito commented May 1, 2024

I think this could merge. @joelanford did @perdasilva address the naming problem sufficiently?

@joelanford joelanford added this pull request to the merge queue May 2, 2024
Merged via the queue into operator-framework:master with commit 9b28021 May 2, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants