diff --git a/pkg/api/pod/util.go b/pkg/api/pod/util.go index d519c9a25f..1d8dbf4846 100644 --- a/pkg/api/pod/util.go +++ b/pkg/api/pod/util.go @@ -232,9 +232,9 @@ func UpdatePodCondition(status *api.PodStatus, condition *api.PodCondition) bool return !isEqual } -// DropDisabledAlphaFields removes disabled fields from the pod spec. +// DropDisabledFields removes disabled fields from the pod spec. // This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pod spec. -func DropDisabledAlphaFields(podSpec *api.PodSpec) { +func DropDisabledFields(podSpec *api.PodSpec) { if !utilfeature.DefaultFeatureGate.Enabled(features.PodPriority) { podSpec.Priority = nil podSpec.PriorityClassName = "" diff --git a/pkg/api/pod/util_test.go b/pkg/api/pod/util_test.go index afbaa8fd69..f5bf91e945 100644 --- a/pkg/api/pod/util_test.go +++ b/pkg/api/pod/util_test.go @@ -307,7 +307,7 @@ func TestDropAlphaVolumeDevices(t *testing.T) { defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, true)() // now test dropping the fields - should not be dropped - DropDisabledAlphaFields(&testPod.Spec) + DropDisabledFields(&testPod.Spec) // check to make sure VolumeDevices is still present // if featureset is set to true @@ -322,14 +322,14 @@ func TestDropAlphaVolumeDevices(t *testing.T) { defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.BlockVolume, false)() // now test dropping the fields - DropDisabledAlphaFields(&testPod.Spec) + DropDisabledFields(&testPod.Spec) // check to make sure VolumeDevices is nil // if featureset is set to false if testPod.Spec.Containers[0].VolumeDevices != nil { - t.Error("DropDisabledAlphaFields for Containers failed") + t.Error("DropDisabledFields for Containers failed") } if testPod.Spec.InitContainers[0].VolumeDevices != nil { - t.Error("DropDisabledAlphaFields for InitContainers failed") + t.Error("DropDisabledFields for InitContainers failed") } } diff --git a/pkg/registry/apps/daemonset/strategy.go b/pkg/registry/apps/daemonset/strategy.go index d3e956bcd3..e635bfda63 100644 --- a/pkg/registry/apps/daemonset/strategy.go +++ b/pkg/registry/apps/daemonset/strategy.go @@ -75,7 +75,7 @@ func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Objec daemonSet.Spec.TemplateGeneration = 1 } - pod.DropDisabledAlphaFields(&daemonSet.Spec.Template.Spec) + pod.DropDisabledFields(&daemonSet.Spec.Template.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -83,8 +83,8 @@ func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime. newDaemonSet := obj.(*apps.DaemonSet) oldDaemonSet := old.(*apps.DaemonSet) - pod.DropDisabledAlphaFields(&newDaemonSet.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldDaemonSet.Spec.Template.Spec) + pod.DropDisabledFields(&newDaemonSet.Spec.Template.Spec) + pod.DropDisabledFields(&oldDaemonSet.Spec.Template.Spec) // update is not allowed to set status newDaemonSet.Status = oldDaemonSet.Status diff --git a/pkg/registry/apps/deployment/strategy.go b/pkg/registry/apps/deployment/strategy.go index 1b96036da5..e3d70031a3 100644 --- a/pkg/registry/apps/deployment/strategy.go +++ b/pkg/registry/apps/deployment/strategy.go @@ -73,7 +73,7 @@ func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obje deployment.Status = apps.DeploymentStatus{} deployment.Generation = 1 - pod.DropDisabledAlphaFields(&deployment.Spec.Template.Spec) + pod.DropDisabledFields(&deployment.Spec.Template.Spec) } // Validate validates a new deployment. @@ -97,8 +97,8 @@ func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime oldDeployment := old.(*apps.Deployment) newDeployment.Status = oldDeployment.Status - pod.DropDisabledAlphaFields(&newDeployment.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldDeployment.Spec.Template.Spec) + pod.DropDisabledFields(&newDeployment.Spec.Template.Spec) + pod.DropDisabledFields(&oldDeployment.Spec.Template.Spec) // Spec updates bump the generation so that we can distinguish between // scaling events and template changes, annotation updates bump the generation diff --git a/pkg/registry/apps/replicaset/strategy.go b/pkg/registry/apps/replicaset/strategy.go index 9e3fe3ecf5..18d09d7f58 100644 --- a/pkg/registry/apps/replicaset/strategy.go +++ b/pkg/registry/apps/replicaset/strategy.go @@ -80,7 +80,7 @@ func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { rs.Generation = 1 - pod.DropDisabledAlphaFields(&rs.Spec.Template.Spec) + pod.DropDisabledFields(&rs.Spec.Template.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -90,8 +90,8 @@ func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) // update is not allowed to set status newRS.Status = oldRS.Status - pod.DropDisabledAlphaFields(&newRS.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldRS.Spec.Template.Spec) + pod.DropDisabledFields(&newRS.Spec.Template.Spec) + pod.DropDisabledFields(&oldRS.Spec.Template.Spec) // Any changes to the spec increment the generation number, any changes to the // status should reflect the generation number of the corresponding object. We push diff --git a/pkg/registry/apps/statefulset/strategy.go b/pkg/registry/apps/statefulset/strategy.go index af500f8af4..0094429201 100644 --- a/pkg/registry/apps/statefulset/strategy.go +++ b/pkg/registry/apps/statefulset/strategy.go @@ -72,7 +72,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obj statefulSet.Generation = 1 - pod.DropDisabledAlphaFields(&statefulSet.Spec.Template.Spec) + pod.DropDisabledFields(&statefulSet.Spec.Template.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -82,8 +82,8 @@ func (statefulSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim // Update is not allowed to set status newStatefulSet.Status = oldStatefulSet.Status - pod.DropDisabledAlphaFields(&newStatefulSet.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldStatefulSet.Spec.Template.Spec) + pod.DropDisabledFields(&newStatefulSet.Spec.Template.Spec) + pod.DropDisabledFields(&oldStatefulSet.Spec.Template.Spec) // Any changes to the spec increment the generation number, any changes to the // status should reflect the generation number of the corresponding object. diff --git a/pkg/registry/batch/cronjob/strategy.go b/pkg/registry/batch/cronjob/strategy.go index a59c2b96e6..82bd78496a 100644 --- a/pkg/registry/batch/cronjob/strategy.go +++ b/pkg/registry/batch/cronjob/strategy.go @@ -68,7 +68,7 @@ func (cronJobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) cronJob := obj.(*batch.CronJob) cronJob.Status = batch.CronJobStatus{} - pod.DropDisabledAlphaFields(&cronJob.Spec.JobTemplate.Spec.Template.Spec) + pod.DropDisabledFields(&cronJob.Spec.JobTemplate.Spec.Template.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -77,8 +77,8 @@ func (cronJobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Ob oldCronJob := old.(*batch.CronJob) newCronJob.Status = oldCronJob.Status - pod.DropDisabledAlphaFields(&newCronJob.Spec.JobTemplate.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldCronJob.Spec.JobTemplate.Spec.Template.Spec) + pod.DropDisabledFields(&newCronJob.Spec.JobTemplate.Spec.Template.Spec) + pod.DropDisabledFields(&oldCronJob.Spec.JobTemplate.Spec.Template.Spec) } // Validate validates a new scheduled job. diff --git a/pkg/registry/batch/job/strategy.go b/pkg/registry/batch/job/strategy.go index e1ec177765..8fc8881132 100644 --- a/pkg/registry/batch/job/strategy.go +++ b/pkg/registry/batch/job/strategy.go @@ -80,7 +80,7 @@ func (jobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { job.Spec.TTLSecondsAfterFinished = nil } - pod.DropDisabledAlphaFields(&job.Spec.Template.Spec) + pod.DropDisabledFields(&job.Spec.Template.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -94,8 +94,8 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object oldJob.Spec.TTLSecondsAfterFinished = nil } - pod.DropDisabledAlphaFields(&newJob.Spec.Template.Spec) - pod.DropDisabledAlphaFields(&oldJob.Spec.Template.Spec) + pod.DropDisabledFields(&newJob.Spec.Template.Spec) + pod.DropDisabledFields(&oldJob.Spec.Template.Spec) } // Validate validates a new job. diff --git a/pkg/registry/core/pod/strategy.go b/pkg/registry/core/pod/strategy.go index 4c2ab6becb..5282882476 100644 --- a/pkg/registry/core/pod/strategy.go +++ b/pkg/registry/core/pod/strategy.go @@ -73,7 +73,7 @@ func (podStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { QOSClass: qos.GetPodQOS(pod), } - podutil.DropDisabledAlphaFields(&pod.Spec) + podutil.DropDisabledFields(&pod.Spec) } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. @@ -82,8 +82,8 @@ func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object oldPod := old.(*api.Pod) newPod.Status = oldPod.Status - podutil.DropDisabledAlphaFields(&newPod.Spec) - podutil.DropDisabledAlphaFields(&oldPod.Spec) + podutil.DropDisabledFields(&newPod.Spec) + podutil.DropDisabledFields(&oldPod.Spec) } // Validate validates a new pod. diff --git a/pkg/registry/core/podtemplate/strategy.go b/pkg/registry/core/podtemplate/strategy.go index 83c516fc88..bddc4752c2 100644 --- a/pkg/registry/core/podtemplate/strategy.go +++ b/pkg/registry/core/podtemplate/strategy.go @@ -47,7 +47,7 @@ func (podTemplateStrategy) NamespaceScoped() bool { func (podTemplateStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { template := obj.(*api.PodTemplate) - pod.DropDisabledAlphaFields(&template.Template.Spec) + pod.DropDisabledFields(&template.Template.Spec) } // Validate validates a new pod template. @@ -70,8 +70,8 @@ func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim newTemplate := obj.(*api.PodTemplate) oldTemplate := old.(*api.PodTemplate) - pod.DropDisabledAlphaFields(&newTemplate.Template.Spec) - pod.DropDisabledAlphaFields(&oldTemplate.Template.Spec) + pod.DropDisabledFields(&newTemplate.Template.Spec) + pod.DropDisabledFields(&oldTemplate.Template.Spec) } // ValidateUpdate is the default update validation for an end user. diff --git a/pkg/registry/core/replicationcontroller/strategy.go b/pkg/registry/core/replicationcontroller/strategy.go index 0909efc6e7..ed39903124 100644 --- a/pkg/registry/core/replicationcontroller/strategy.go +++ b/pkg/registry/core/replicationcontroller/strategy.go @@ -81,7 +81,7 @@ func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { controller.Generation = 1 if controller.Spec.Template != nil { - pod.DropDisabledAlphaFields(&controller.Spec.Template.Spec) + pod.DropDisabledFields(&controller.Spec.Template.Spec) } } @@ -93,10 +93,10 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) newController.Status = oldController.Status if oldController.Spec.Template != nil { - pod.DropDisabledAlphaFields(&oldController.Spec.Template.Spec) + pod.DropDisabledFields(&oldController.Spec.Template.Spec) } if newController.Spec.Template != nil { - pod.DropDisabledAlphaFields(&newController.Spec.Template.Spec) + pod.DropDisabledFields(&newController.Spec.Template.Spec) } // Any changes to the spec increment the generation number, any changes to the