-
Notifications
You must be signed in to change notification settings - Fork 98
OCPBUGS-86895: Ensure packageserver pod seccompProfile is always set #1341
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,21 @@ func withAffinity(affinity *corev1.Affinity) func(*olmv1alpha1.ClusterServiceVer | |
| csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[0].Spec.Template.Spec.Affinity = affinity | ||
| } | ||
| } | ||
|
|
||
| func withoutSeccompProfile() testCSVOption { | ||
| return func(csv *olmv1alpha1.ClusterServiceVersion) { | ||
| podSpec := &csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[0].Spec.Template.Spec | ||
| if podSpec.SecurityContext != nil { | ||
| podSpec.SecurityContext.SeccompProfile = nil | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func withNilPodSecurityContext() testCSVOption { | ||
| return func(csv *olmv1alpha1.ClusterServiceVersion) { | ||
| csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[0].Spec.Template.Spec.SecurityContext = nil | ||
| } | ||
| } | ||
| func withRollingUpdateStrategy(strategy *appsv1.RollingUpdateDeployment) func(*olmv1alpha1.ClusterServiceVersion) { | ||
| return func(csv *olmv1alpha1.ClusterServiceVersion) { | ||
| csv.Spec.InstallStrategy.StrategySpec.DeploymentSpecs[0].Spec.Strategy.RollingUpdate = strategy | ||
|
|
@@ -255,6 +270,27 @@ func TestEnsureCSV(t *testing.T) { | |
| inputCSV: newTestCSV(withReplicas(singleReplicas), withRollingUpdateStrategy(emptyRollout), withAffinity(&corev1.Affinity{})), | ||
| expectedCSV: newTestCSV(withReplicas(singleReplicas), withRollingUpdateStrategy(emptyRollout), withAffinity(&corev1.Affinity{})), | ||
| }, | ||
| { | ||
| name: "Modified/HighlyAvailable/MissingSeccompProfile", | ||
| want: wanted{true, nil}, | ||
| highlyAvailable: true, | ||
| inputCSV: newTestCSV(withReplicas(defaultReplicas), withRollingUpdateStrategy(defaultRollout), withAffinity(defaultAffinity), withoutSeccompProfile()), | ||
| expectedCSV: newTestCSV(withReplicas(defaultReplicas), withRollingUpdateStrategy(defaultRollout), withAffinity(defaultAffinity)), | ||
| }, | ||
| { | ||
| name: "Modified/SingleReplica/MissingSeccompProfile", | ||
| want: wanted{true, nil}, | ||
| highlyAvailable: false, | ||
| inputCSV: newTestCSV(withReplicas(singleReplicas), withRollingUpdateStrategy(emptyRollout), withAffinity(&corev1.Affinity{}), withoutSeccompProfile()), | ||
| expectedCSV: newTestCSV(withReplicas(singleReplicas), withRollingUpdateStrategy(emptyRollout), withAffinity(&corev1.Affinity{})), | ||
| }, | ||
| { | ||
| name: "Modified/HighlyAvailable/NilPodSecurityContext", | ||
| want: wanted{true, nil}, | ||
| highlyAvailable: true, | ||
| inputCSV: newTestCSV(withReplicas(defaultReplicas), withRollingUpdateStrategy(defaultRollout), withAffinity(defaultAffinity), withNilPodSecurityContext()), | ||
| expectedCSV: newTestCSV(withReplicas(defaultReplicas), withRollingUpdateStrategy(defaultRollout), withAffinity(defaultAffinity)), | ||
| }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to have a case of "Modified/SingleReplica/NilPodSecurityContext"? My guess is the intension is that HA is more important here and for SingleReplica we do not need as much coverage. A case of "Modified/SingleReplica/MissingSeccompProfile" seems enough.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be something to consider in the future.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :resolved. |
||
| } | ||
|
|
||
| for _, tc := range tt { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(probably because of my limited knowledge on
SecurityContext) I do not see why we enforcecorev1.SeccompProfileTypeRuntimeDefault.But it looks like a natural choice out of the 3 candidates.
operator-framework-olm/vendor/k8s.io/api/core/v1/types.go
Lines 5006 to 5014 in 5bebe93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's basically the reason; we don't want to rely on
LocalhostorUnconfinedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:resolved. Thanks for the answers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "RuntimeDefault" is usually added when the Object is processed by the controller. By default, any pod running under
restricted-v2should have the seccompProfile set toRuntimeDefault. However, it is better to explicitly define it in the deployment as we always want to have the default value.Just adding my thoughts about the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the intent to explicitly define the setting.