-
Notifications
You must be signed in to change notification settings - Fork 54
OCPBUGS-58313: Admit sysctls based on the worker node kernel version instead of the current node kernel version #151
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: master
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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import ( | |
|
|
||
| "github.com/openshift/api/security" | ||
| securityv1 "github.com/openshift/api/security/v1" | ||
| "github.com/openshift/apiserver-library-go/pkg/securitycontextconstraints/sysctl" | ||
| sccsort "github.com/openshift/apiserver-library-go/pkg/securitycontextconstraints/util/sort" | ||
| securityv1listers "github.com/openshift/client-go/security/listers/security/v1" | ||
| "github.com/openshift/library-go/pkg/security/uid" | ||
|
|
@@ -164,7 +165,7 @@ func constraintSupportsGroup(group string, constraintGroups []string) bool { | |
|
|
||
| // CreateProvidersFromConstraints creates providers from the constraints supplied, including | ||
| // looking up pre-allocated values if necessary using the pod's namespace. | ||
| func CreateProvidersFromConstraints(ctx context.Context, namespaceName string, sccs []*securityv1.SecurityContextConstraints, namespaceLister corev1listers.NamespaceLister) ([]SecurityContextConstraintsProvider, []error) { | ||
| func CreateProvidersFromConstraints(ctx context.Context, namespaceName string, sccs []*securityv1.SecurityContextConstraints, namespaceLister corev1listers.NamespaceLister, nodeLister corev1listers.NodeLister) ([]SecurityContextConstraintsProvider, []error) { | ||
| var ( | ||
| // namespace is declared here for reuse but we will not fetch it unless required by the matched constraints | ||
| namespace *corev1.Namespace | ||
|
|
@@ -207,7 +208,7 @@ func CreateProvidersFromConstraints(ctx context.Context, namespaceName string, s | |
| provider SecurityContextConstraintsProvider | ||
| err error | ||
| ) | ||
| provider, err = CreateProviderFromConstraint(namespace, constraint) | ||
| provider, err = CreateProviderFromConstraint(namespace, constraint, nodeLister) | ||
| if err != nil { | ||
| errs = append(errs, err) | ||
| continue | ||
|
|
@@ -218,7 +219,7 @@ func CreateProvidersFromConstraints(ctx context.Context, namespaceName string, s | |
| } | ||
|
|
||
| // CreateProviderFromConstraint creates a SecurityContextConstraintProvider from a SecurityContextConstraint | ||
| func CreateProviderFromConstraint(namespace *corev1.Namespace, constraint *securityv1.SecurityContextConstraints) (SecurityContextConstraintsProvider, error) { | ||
| func CreateProviderFromConstraint(namespace *corev1.Namespace, constraint *securityv1.SecurityContextConstraints, nodeLister corev1listers.NodeLister) (SecurityContextConstraintsProvider, error) { | ||
| var err error | ||
|
|
||
| // Make a copy of the constraint so we don't mutate the store's cache | ||
|
|
@@ -258,7 +259,7 @@ func CreateProviderFromConstraint(namespace *corev1.Namespace, constraint *secur | |
| } | ||
|
|
||
| // Create the provider | ||
| provider, err := NewSimpleProvider(constraint) | ||
| provider, err := NewSimpleProvider(constraint, sysctl.SafeSysctlAllowlist(nodeLister)) | ||
|
Contributor
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. This calculation doesn't change per request, right? So we could move it out of the for-loop, right? Due to the fact that But we could have If we move the check out of the for-loop. It would be good to figure out how many nodes big clusters have as we could improve the performance drastically on clusters with plenty of Nodes. This would create a With 10k Nodes and 10 SCCs those numbers change drastically:
|
||
| if err != nil { | ||
| return nil, fmt.Errorf("error creating provider for SCC %s in namespace %s: %v", constraint.Name, namespace.GetName(), err) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
From a code / maintenance perspective, I must say that handing the nodeLister 6 levels down doesn't look good. We are coupling all those functions with the nodeLister. E.g.:
It reads well if you transform a scc into a provider, but now you have a scc and a nodeLister?!
Couldn't we check the legit sysctls and extend the constraints.AllowedUnsafeSysctls or adjust the SimpleProvider to hold those specificly, so that we don't pass c.nodeLister down? It would read better like so:
or
Everything else might be more effort, like some Factory or so.
WDYT?
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.
Thank you for suggestion.
I've refactored
NewSimpleProviderto takeavailableSysCtls []stringinstead ofnodeLister.