Promote sysctl annotations to fields#63717
Promote sysctl annotations to fields#63717k8s-github-robot merged 4 commits intokubernetes:masterfrom
Conversation
There was a problem hiding this comment.
they got added automatically in the generation commit, but having them in this commit makes them easier to review
There was a problem hiding this comment.
Moved from the generated code.
There was a problem hiding this comment.
It shouldn't be empty, right?
There was a problem hiding this comment.
Make member name lowercase as it will appear in the api doc: s/Sysctls/sysctls/
There was a problem hiding this comment.
If we don't support old annotations, perhaps, we don't have to support PSP in the extensions API Group?
There was a problem hiding this comment.
What is the semantics of empty lists vs. nil in the annotations? Does empty list mean "no sysctls allowed at all" vs. nil "use the default set" ?
There was a problem hiding this comment.
The original functionality is respected. So
- If the list is empty -> No sysctls are allowed
- If the list is nil -> Use the default sysctls patterns
There was a problem hiding this comment.
Make member name lowercase as it will appear in the api doc: s/Sysctls/sysctls/
Done
There was a problem hiding this comment.
The nil/empty distinction is lost when roundtripping via serialized protobuf, and makes for a fairly confusing API
There was a problem hiding this comment.
The nil/empty distinction is lost
Don't we test this in roundtrip tests? We should.
If we change the API semantics (I don't feel strongly, I tend to agree that it is confusing), we should doc that. Do we want to?
There was a problem hiding this comment.
Make member name lowercase as it will appear in the api doc: s/Sysctls/sysctls/
|
/uncc |
Hmm, for some reason the pod.securityContext.Sysctl list is not decoded correctly. The body before decoding in the apiserver: Once can notice the After decoding the EDIT: So the byte stream is properly unmarshalled into v1.Pod. Though, v1.Pod -> core.Pod drops the Sysctls :-| EDIT2. Grrr, forgot to update |
pkg/apis/core/types.go
Outdated
pkg/apis/policy/types.go
Outdated
There was a problem hiding this comment.
remove json tags from internal types
|
@jberkus thanks |
The main loop validating the sysctls during admission rewritten into: for i, sysctl := range sysctls {
switch {
case s.isForbidden(sysctl.Name):
..."sysctl %q is not allowed", sysctl.Name...
case s.isSafe(sysctl.Name):
continue
case s.isAllowedUnsafe(sysctl.Name):
continue
default:
..."unsafe sysctl %q is not allowed", sysctl.Name...
}
}Now, all sysctls (no matter if thery safe or unsafe) are subject to check if they are forbidden. If a sysctl is forbidden => goodbye. Then the default is safe and is allowed unsafe check. Otherwise rejected.
Comment above
Done. Both lists are checked if there is any sysctl (either plain or a pattern) that is covered in other one and visa verse.
Done. |
There was a problem hiding this comment.
forbiddenSysctlsFldPath.Index(i) and forbiddenSysctls[i] below should be using j index saved here, not i
There was a problem hiding this comment.
Copy-paste thing, shame on me. Fixed
There was a problem hiding this comment.
validatePodSecurityPolicySysctls is called unconditionally... returning an error unconditionally here means disabling the feature gate would block write access to PSPs
There was a problem hiding this comment.
Right. This was the place with if sysctl not set -> return nil was. Removing that caused this. I will put it back.
There was a problem hiding this comment.
field.Invalid, "if '*' is present, must not specify other sysctls"
|
three validation comments, two blocking (the invalid index one and the one unconditionally failing if the feature gate is disabled) lgtm once those are resolved |
pkg/apis/policy/types.go
Outdated
There was a problem hiding this comment.
follow-up: we should maybe also mention that the kubelet has to whitelist them explicitly.
There was a problem hiding this comment.
follow-up: mention that these must not be forbidden.
There was a problem hiding this comment.
can be formulated in a neutral way, like: "It depends on the node to accept these unsafe sysctl as well".
There was a problem hiding this comment.
I will mention it.
There was a problem hiding this comment.
I guess the decoder will give us non-nil on an empty list? Do we want to reject an empty list?
There was a problem hiding this comment.
nil or empty list has the same semantics here. I will update it to check the len.
pkg/kubelet/kubelet.go
Outdated
There was a problem hiding this comment.
so in server side validation we reject every sysctl, in the kubelet we ignore them. Is this intentional?
There was a problem hiding this comment.
It's not intentional. I will fix that to reject on the kubelet side.
There was a problem hiding this comment.
Oh, this one is actually intentional.
|
API, validation, and PSP changes LGTM |
|
lgtm also from my side. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, ingvagabund, liggitt, sjenning The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process @derekwaynecarr @ingvagabund @liggitt @sjenning @tallclair @vishh Pull Request Labels
|
|
New changes are detected. LGTM label has been removed. |
|
/test pull-kubernetes-e2e-gce |
|
/retest |
1 similar comment
|
/retest |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
Promoting experimental sysctl feature from annotations to API fields.
Special notes for your reviewer:
Following sysctl KEP: kubernetes/community#2093
Release note:
TODO: