mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
cleanup TODOs in dockershim
This commit is contained in:
parent
3aee57d4ae
commit
f8e5f81fed
@ -133,8 +133,6 @@ func generateMountBindings(mounts []*runtimeApi.Mount) (result []string) {
|
|||||||
// does not provide an SELinux context relabeling will label the volume with
|
// does not provide an SELinux context relabeling will label the volume with
|
||||||
// the container's randomly allocated MCS label. This would restrict access
|
// the container's randomly allocated MCS label. This would restrict access
|
||||||
// to the volume to the container which mounts it first.
|
// to the volume to the container which mounts it first.
|
||||||
// TODO: always relabel if SELinux is enabled and the volume support relabeling
|
|
||||||
// (refer #33951 and #33663).
|
|
||||||
if m.GetSelinuxRelabel() {
|
if m.GetSelinuxRelabel() {
|
||||||
if readOnly {
|
if readOnly {
|
||||||
bind += ",Z"
|
bind += ",Z"
|
||||||
|
@ -36,12 +36,7 @@ func applySandboxSecurityContext(lc *runtimeapi.LinuxPodSandboxConfig, config *d
|
|||||||
var sc *runtimeapi.LinuxContainerSecurityContext
|
var sc *runtimeapi.LinuxContainerSecurityContext
|
||||||
if lc.SecurityContext != nil {
|
if lc.SecurityContext != nil {
|
||||||
sc = &runtimeapi.LinuxContainerSecurityContext{
|
sc = &runtimeapi.LinuxContainerSecurityContext{
|
||||||
// TODO: We skip application of supplemental groups to the
|
SupplementalGroups: lc.SecurityContext.SupplementalGroups,
|
||||||
// sandbox container to work around a runc issue which
|
|
||||||
// requires containers to have the '/etc/group'. For more
|
|
||||||
// information see: https://github.com/opencontainers/runc/pull/313.
|
|
||||||
// This can be removed once the fix makes it into the required
|
|
||||||
// version of docker.
|
|
||||||
RunAsUser: lc.SecurityContext.RunAsUser,
|
RunAsUser: lc.SecurityContext.RunAsUser,
|
||||||
ReadonlyRootfs: lc.SecurityContext.ReadonlyRootfs,
|
ReadonlyRootfs: lc.SecurityContext.ReadonlyRootfs,
|
||||||
SelinuxOptions: lc.SecurityContext.SelinuxOptions,
|
SelinuxOptions: lc.SecurityContext.SelinuxOptions,
|
||||||
@ -128,7 +123,7 @@ func modifyNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, sandboxID string
|
|||||||
if sandboxID == "" {
|
if sandboxID == "" {
|
||||||
modifyHostNetworkOptionForSandbox(hostNetwork, hostConfig)
|
modifyHostNetworkOptionForSandbox(hostNetwork, hostConfig)
|
||||||
} else {
|
} else {
|
||||||
// Set for container is sandboxID is provided.
|
// Set for container if sandboxID is provided.
|
||||||
modifyHostNetworkOptionForContainer(hostNetwork, sandboxID, hostConfig)
|
modifyHostNetworkOptionForContainer(hostNetwork, sandboxID, hostConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ func TestModifyContainerConfig(t *testing.T) {
|
|||||||
|
|
||||||
func TestModifyHostConfig(t *testing.T) {
|
func TestModifyHostConfig(t *testing.T) {
|
||||||
priv := true
|
priv := true
|
||||||
|
setNetworkHC := &dockercontainer.HostConfig{
|
||||||
|
NetworkMode: "none",
|
||||||
|
}
|
||||||
setPrivSC := &runtimeapi.LinuxContainerSecurityContext{}
|
setPrivSC := &runtimeapi.LinuxContainerSecurityContext{}
|
||||||
setPrivSC.Privileged = &priv
|
setPrivSC.Privileged = &priv
|
||||||
setPrivHC := &dockercontainer.HostConfig{
|
setPrivHC := &dockercontainer.HostConfig{
|
||||||
@ -92,6 +95,11 @@ func TestModifyHostConfig(t *testing.T) {
|
|||||||
sc: fullValidSecurityContext(),
|
sc: fullValidSecurityContext(),
|
||||||
expected: fullValidHostConfig(),
|
expected: fullValidHostConfig(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "empty container.SecurityContext",
|
||||||
|
sc: &runtimeapi.LinuxContainerSecurityContext{},
|
||||||
|
expected: setNetworkHC,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "container.SecurityContext.Privileged",
|
name: "container.SecurityContext.Privileged",
|
||||||
sc: setPrivSC,
|
sc: setPrivSC,
|
||||||
|
@ -149,6 +149,9 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxLinuxConfig(pod *api.Pod,
|
|||||||
RunAsUser: sc.RunAsUser,
|
RunAsUser: sc.RunAsUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sc.FSGroup != nil {
|
||||||
|
lc.SecurityContext.SupplementalGroups = append(lc.SecurityContext.SupplementalGroups, *sc.FSGroup)
|
||||||
|
}
|
||||||
if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 {
|
if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 {
|
||||||
lc.SecurityContext.SupplementalGroups = append(lc.SecurityContext.SupplementalGroups, groups...)
|
lc.SecurityContext.SupplementalGroups = append(lc.SecurityContext.SupplementalGroups, groups...)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user