mirror of https://github.com/k3s-io/k3s
PodSecurityPolicy: avoid unnecessary mutation of supplemental groups
parent
cfb490e3a1
commit
abc7c077e1
|
@ -34,7 +34,7 @@ func NewRunAsAny() (GroupStrategy, error) {
|
||||||
|
|
||||||
// Generate creates the group based on policy rules. This strategy returns an empty slice.
|
// Generate creates the group based on policy rules. This strategy returns an empty slice.
|
||||||
func (s *runAsAny) Generate(pod *api.Pod) ([]int64, error) {
|
func (s *runAsAny) Generate(pod *api.Pod) ([]int64, error) {
|
||||||
return []int64{}, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a single value to be applied. This is used for FSGroup. This strategy returns nil.
|
// Generate a single value to be applied. This is used for FSGroup. This strategy returns nil.
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (s *simpleProvider) CreatePodSecurityContext(pod *api.Pod) (*api.PodSecurit
|
||||||
}
|
}
|
||||||
annotations := maps.CopySS(pod.Annotations)
|
annotations := maps.CopySS(pod.Annotations)
|
||||||
|
|
||||||
if len(sc.SupplementalGroups) == 0 {
|
if sc.SupplementalGroups == nil {
|
||||||
supGroups, err := s.strategies.SupplementalGroupStrategy.Generate(pod)
|
supGroups, err := s.strategies.SupplementalGroupStrategy.Generate(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
|
@ -993,7 +993,7 @@ func TestAdmitSupplementalGroups(t *testing.T) {
|
||||||
pod: goodPod(),
|
pod: goodPod(),
|
||||||
psps: []*extensions.PodSecurityPolicy{runAsAny},
|
psps: []*extensions.PodSecurityPolicy{runAsAny},
|
||||||
shouldPass: true,
|
shouldPass: true,
|
||||||
expectedSupGroups: []int64{},
|
expectedSupGroups: nil,
|
||||||
expectedPSP: runAsAny.Name,
|
expectedPSP: runAsAny.Name,
|
||||||
},
|
},
|
||||||
"runAsAny pod request": {
|
"runAsAny pod request": {
|
||||||
|
|
Loading…
Reference in New Issue