Skip to content
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

1.13: Fix incorrect procMount defaulting #78882

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions pkg/api/pod/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,22 @@ func DropDisabledProcMountField(podSpec *api.PodSpec) {
defProcMount := api.DefaultProcMount
for i := range podSpec.Containers {
if podSpec.Containers[i].SecurityContext != nil {
podSpec.Containers[i].SecurityContext.ProcMount = &defProcMount
if podSpec.Containers[i].SecurityContext.ProcMount != nil {
// The ProcMount field was improperly forced to non-nil in 1.12.
// If the feature is disabled, and the ProcMount field is present in the incoming object, force to the default value.
// Note: we cannot force the field to nil when the feature is disabled because it causes a diff against previously persisted data.
podSpec.Containers[i].SecurityContext.ProcMount = &defProcMount
}
}
}
for i := range podSpec.InitContainers {
if podSpec.InitContainers[i].SecurityContext != nil {
podSpec.InitContainers[i].SecurityContext.ProcMount = &defProcMount
if podSpec.InitContainers[i].SecurityContext.ProcMount != nil {
// The ProcMount field was improperly forced to non-nil in 1.12.
// If the feature is disabled, and the ProcMount field is present in the incoming object, force to the default value.
// Note: we cannot force the field to nil when the feature is disabled because it causes a diff against previously persisted data.
podSpec.InitContainers[i].SecurityContext.ProcMount = &defProcMount
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/deployment_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ func NewDeployment(deploymentName string, replicas int32, podLabels map[string]s
TerminationGracePeriodSeconds: &zero,
Containers: []v1.Container{
{
Name: imageName,
Image: image,
Name: imageName,
Image: image,
SecurityContext: &v1.SecurityContext{},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions test/e2e/framework/jobs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func NewTestJob(behavior, name string, rPol v1.RestartPolicy, parallelism, compl
Name: "data",
},
},
SecurityContext: &v1.SecurityContext{},
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/framework/rs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string]
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: imageName,
Image: image,
Name: imageName,
Image: image,
SecurityContext: &v1.SecurityContext{},
},
},
},
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/framework/statefulset_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,10 @@ func NewStatefulSet(name, ns, governingSvcName string, replicas int32, statefulP
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "nginx",
Image: imageutils.GetE2EImage(imageutils.Nginx),
VolumeMounts: mounts,
Name: "nginx",
Image: imageutils.GetE2EImage(imageutils.Nginx),
VolumeMounts: mounts,
SecurityContext: &v1.SecurityContext{},
},
},
Volumes: vols,
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/upgrades/apps/daemonsets.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func (t *DaemonSetUpgradeTest) Setup(f *framework.Framework) {
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: daemonSetName,
Image: image,
Ports: []v1.ContainerPort{{ContainerPort: 9376}},
Name: daemonSetName,
Image: image,
Ports: []v1.ContainerPort{{ContainerPort: 9376}},
SecurityContext: &v1.SecurityContext{},
},
},
},
Expand Down