From 5812c876f77daa45234107150a77c852c0d50b52 Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Wed, 5 Apr 2017 22:29:46 +0800 Subject: [PATCH] kuberuntime: set namespsace options regardless of security context --- pkg/kubelet/kuberuntime/security_context.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/kubelet/kuberuntime/security_context.go b/pkg/kubelet/kuberuntime/security_context.go index 4ccbe1a45b6..0cc784fc3aa 100644 --- a/pkg/kubelet/kuberuntime/security_context.go +++ b/pkg/kubelet/kuberuntime/security_context.go @@ -41,24 +41,24 @@ func (m *kubeGenericRuntimeManager) determineEffectiveSecurityContext(pod *v1.Po } // set namespace options and supplemental groups. - podSc := pod.Spec.SecurityContext - if podSc == nil { - return synthesized - } synthesized.NamespaceOptions = &runtimeapi.NamespaceOption{ HostNetwork: pod.Spec.HostNetwork, HostIpc: pod.Spec.HostIPC, HostPid: pod.Spec.HostPID, } - if podSc.FSGroup != nil { - synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup) + podSc := pod.Spec.SecurityContext + if podSc != nil { + if podSc.FSGroup != nil { + synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup) + } + + if podSc.SupplementalGroups != nil { + synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...) + } } if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 { synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, groups...) } - if podSc.SupplementalGroups != nil { - synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...) - } return synthesized }