Skip to content

Add restrictive security context to registry pod and init containers#7040

Open
kaovilai wants to merge 1 commit intooperator-framework:masterfrom
kaovilai:secContextInitContainer
Open

Add restrictive security context to registry pod and init containers#7040
kaovilai wants to merge 1 commit intooperator-framework:masterfrom
kaovilai:secContextInitContainer

Conversation

@kaovilai
Copy link
Contributor

Fixes #7039

Signed-off-by: Tiger Kaovilai passawit.kaovilai@gmail.com

Description of the change:

Motivation for the change:

Checklist

If the pull request includes user-facing changes, extra documentation is required:

Copilot AI review requested due to automatic review settings January 16, 2026 10:26
@kaovilai kaovilai force-pushed the secContextInitContainer branch from 79fd63e to e9a876b Compare January 16, 2026 10:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances security by applying restrictive security contexts to init containers in the FBC registry pod, addressing issue #7039. Previously, only the main container received the restrictive security context when the --security-context-config=restricted flag was used.

Changes:

  • Refactored security context creation into a reusable variable
  • Added security context application to all init containers in the FBC registry pod

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +163 to +166
// Update all init containers with the same restrictive security context
for i := range f.pod.Spec.InitContainers {
f.pod.Spec.InitContainers[i].SecurityContext = restrictedSecurityContext
}
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The new functionality that applies the restrictive security context to init containers lacks test coverage. The test file fbc_registry_pod_test.go has comprehensive tests for other functionality but does not verify that init containers receive the security context when SecurityContext is set to 'restricted'. Consider adding a test case that creates an FBCRegistryPod with SecurityContext: 'restricted' and verifies that both the main container and init containers have the expected security context settings.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kaovilai Would you mind adding a test for this?

@kaovilai
Copy link
Contributor Author

kaovilai commented Feb 9, 2026

Those with similar issue and cannot wait for this PR can copy openshift/oadp-operator#2078

@acornett21
Copy link
Contributor

@kaovilai Could you rebase this pr?

Fixes operator-framework#7039

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>

Add changelog fragment for init container security context fix

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kaovilai kaovilai force-pushed the secContextInitContainer branch from e9a876b to 5daef89 Compare March 12, 2026 15:09
@kaovilai
Copy link
Contributor Author

dun dun dun!

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.

FBC registry pod init container missing SecurityContext when using --security-context-config=restricted

3 participants