Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
49028df5
Commit
49028df5
authored
Dec 17, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename DropDisabledFields
parent
f77a0706
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
33 additions
and
33 deletions
+33
-33
util.go
pkg/api/pod/util.go
+2
-2
util_test.go
pkg/api/pod/util_test.go
+4
-4
strategy.go
pkg/registry/apps/daemonset/strategy.go
+3
-3
strategy.go
pkg/registry/apps/deployment/strategy.go
+3
-3
strategy.go
pkg/registry/apps/replicaset/strategy.go
+3
-3
strategy.go
pkg/registry/apps/statefulset/strategy.go
+3
-3
strategy.go
pkg/registry/batch/cronjob/strategy.go
+3
-3
strategy.go
pkg/registry/batch/job/strategy.go
+3
-3
strategy.go
pkg/registry/core/pod/strategy.go
+3
-3
strategy.go
pkg/registry/core/podtemplate/strategy.go
+3
-3
strategy.go
pkg/registry/core/replicationcontroller/strategy.go
+3
-3
No files found.
pkg/api/pod/util.go
View file @
49028df5
...
@@ -232,9 +232,9 @@ func UpdatePodCondition(status *api.PodStatus, condition *api.PodCondition) bool
...
@@ -232,9 +232,9 @@ func UpdatePodCondition(status *api.PodStatus, condition *api.PodCondition) bool
return
!
isEqual
return
!
isEqual
}
}
// DropDisabled
Alpha
Fields 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.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pod spec.
func
DropDisabled
Alpha
Fields
(
podSpec
*
api
.
PodSpec
)
{
func
DropDisabledFields
(
podSpec
*
api
.
PodSpec
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
{
podSpec
.
Priority
=
nil
podSpec
.
Priority
=
nil
podSpec
.
PriorityClassName
=
""
podSpec
.
PriorityClassName
=
""
...
...
pkg/api/pod/util_test.go
View file @
49028df5
...
@@ -307,7 +307,7 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
...
@@ -307,7 +307,7 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
true
)()
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
true
)()
// now test dropping the fields - should not be dropped
// now test dropping the fields - should not be dropped
DropDisabled
Alpha
Fields
(
&
testPod
.
Spec
)
DropDisabledFields
(
&
testPod
.
Spec
)
// check to make sure VolumeDevices is still present
// check to make sure VolumeDevices is still present
// if featureset is set to true
// if featureset is set to true
...
@@ -322,14 +322,14 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
...
@@ -322,14 +322,14 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
false
)()
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
false
)()
// now test dropping the fields
// now test dropping the fields
DropDisabled
Alpha
Fields
(
&
testPod
.
Spec
)
DropDisabledFields
(
&
testPod
.
Spec
)
// check to make sure VolumeDevices is nil
// check to make sure VolumeDevices is nil
// if featureset is set to false
// if featureset is set to false
if
testPod
.
Spec
.
Containers
[
0
]
.
VolumeDevices
!=
nil
{
if
testPod
.
Spec
.
Containers
[
0
]
.
VolumeDevices
!=
nil
{
t
.
Error
(
"DropDisabled
Alpha
Fields for Containers failed"
)
t
.
Error
(
"DropDisabledFields for Containers failed"
)
}
}
if
testPod
.
Spec
.
InitContainers
[
0
]
.
VolumeDevices
!=
nil
{
if
testPod
.
Spec
.
InitContainers
[
0
]
.
VolumeDevices
!=
nil
{
t
.
Error
(
"DropDisabled
Alpha
Fields for InitContainers failed"
)
t
.
Error
(
"DropDisabledFields for InitContainers failed"
)
}
}
}
}
pkg/registry/apps/daemonset/strategy.go
View file @
49028df5
...
@@ -75,7 +75,7 @@ func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Objec
...
@@ -75,7 +75,7 @@ func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Objec
daemonSet
.
Spec
.
TemplateGeneration
=
1
daemonSet
.
Spec
.
TemplateGeneration
=
1
}
}
pod
.
DropDisabled
Alpha
Fields
(
&
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.
// 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.
...
@@ -83,8 +83,8 @@ func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
newDaemonSet
:=
obj
.
(
*
apps
.
DaemonSet
)
newDaemonSet
:=
obj
.
(
*
apps
.
DaemonSet
)
oldDaemonSet
:=
old
.
(
*
apps
.
DaemonSet
)
oldDaemonSet
:=
old
.
(
*
apps
.
DaemonSet
)
pod
.
DropDisabled
Alpha
Fields
(
&
newDaemonSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newDaemonSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldDaemonSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldDaemonSet
.
Spec
.
Template
.
Spec
)
// update is not allowed to set status
// update is not allowed to set status
newDaemonSet
.
Status
=
oldDaemonSet
.
Status
newDaemonSet
.
Status
=
oldDaemonSet
.
Status
...
...
pkg/registry/apps/deployment/strategy.go
View file @
49028df5
...
@@ -73,7 +73,7 @@ func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obje
...
@@ -73,7 +73,7 @@ func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obje
deployment
.
Status
=
apps
.
DeploymentStatus
{}
deployment
.
Status
=
apps
.
DeploymentStatus
{}
deployment
.
Generation
=
1
deployment
.
Generation
=
1
pod
.
DropDisabled
Alpha
Fields
(
&
deployment
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
deployment
.
Spec
.
Template
.
Spec
)
}
}
// Validate validates a new deployment.
// Validate validates a new deployment.
...
@@ -97,8 +97,8 @@ func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime
...
@@ -97,8 +97,8 @@ func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime
oldDeployment
:=
old
.
(
*
apps
.
Deployment
)
oldDeployment
:=
old
.
(
*
apps
.
Deployment
)
newDeployment
.
Status
=
oldDeployment
.
Status
newDeployment
.
Status
=
oldDeployment
.
Status
pod
.
DropDisabled
Alpha
Fields
(
&
newDeployment
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newDeployment
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldDeployment
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldDeployment
.
Spec
.
Template
.
Spec
)
// Spec updates bump the generation so that we can distinguish between
// Spec updates bump the generation so that we can distinguish between
// scaling events and template changes, annotation updates bump the generation
// scaling events and template changes, annotation updates bump the generation
...
...
pkg/registry/apps/replicaset/strategy.go
View file @
49028df5
...
@@ -80,7 +80,7 @@ func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
...
@@ -80,7 +80,7 @@ func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
rs
.
Generation
=
1
rs
.
Generation
=
1
pod
.
DropDisabled
Alpha
Fields
(
&
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.
// 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)
...
@@ -90,8 +90,8 @@ func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
// update is not allowed to set status
// update is not allowed to set status
newRS
.
Status
=
oldRS
.
Status
newRS
.
Status
=
oldRS
.
Status
pod
.
DropDisabled
Alpha
Fields
(
&
newRS
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newRS
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldRS
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldRS
.
Spec
.
Template
.
Spec
)
// Any changes to the spec increment the generation number, any changes to the
// 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
// status should reflect the generation number of the corresponding object. We push
...
...
pkg/registry/apps/statefulset/strategy.go
View file @
49028df5
...
@@ -72,7 +72,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obj
...
@@ -72,7 +72,7 @@ func (statefulSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obj
statefulSet
.
Generation
=
1
statefulSet
.
Generation
=
1
pod
.
DropDisabled
Alpha
Fields
(
&
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.
// 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
...
@@ -82,8 +82,8 @@ func (statefulSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
// Update is not allowed to set status
// Update is not allowed to set status
newStatefulSet
.
Status
=
oldStatefulSet
.
Status
newStatefulSet
.
Status
=
oldStatefulSet
.
Status
pod
.
DropDisabled
Alpha
Fields
(
&
newStatefulSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newStatefulSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldStatefulSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldStatefulSet
.
Spec
.
Template
.
Spec
)
// Any changes to the spec increment the generation number, any changes to the
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object.
// status should reflect the generation number of the corresponding object.
...
...
pkg/registry/batch/cronjob/strategy.go
View file @
49028df5
...
@@ -68,7 +68,7 @@ func (cronJobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)
...
@@ -68,7 +68,7 @@ func (cronJobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object)
cronJob
:=
obj
.
(
*
batch
.
CronJob
)
cronJob
:=
obj
.
(
*
batch
.
CronJob
)
cronJob
.
Status
=
batch
.
CronJobStatus
{}
cronJob
.
Status
=
batch
.
CronJobStatus
{}
pod
.
DropDisabled
Alpha
Fields
(
&
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.
// 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
...
@@ -77,8 +77,8 @@ func (cronJobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Ob
oldCronJob
:=
old
.
(
*
batch
.
CronJob
)
oldCronJob
:=
old
.
(
*
batch
.
CronJob
)
newCronJob
.
Status
=
oldCronJob
.
Status
newCronJob
.
Status
=
oldCronJob
.
Status
pod
.
DropDisabled
Alpha
Fields
(
&
newCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
)
}
}
// Validate validates a new scheduled job.
// Validate validates a new scheduled job.
...
...
pkg/registry/batch/job/strategy.go
View file @
49028df5
...
@@ -80,7 +80,7 @@ func (jobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
...
@@ -80,7 +80,7 @@ func (jobStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
job
.
Spec
.
TTLSecondsAfterFinished
=
nil
job
.
Spec
.
TTLSecondsAfterFinished
=
nil
}
}
pod
.
DropDisabled
Alpha
Fields
(
&
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.
// 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
...
@@ -94,8 +94,8 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
oldJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
oldJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
}
}
pod
.
DropDisabled
Alpha
Fields
(
&
newJob
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newJob
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldJob
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldJob
.
Spec
.
Template
.
Spec
)
}
}
// Validate validates a new job.
// Validate validates a new job.
...
...
pkg/registry/core/pod/strategy.go
View file @
49028df5
...
@@ -73,7 +73,7 @@ func (podStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
...
@@ -73,7 +73,7 @@ func (podStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
QOSClass
:
qos
.
GetPodQOS
(
pod
),
QOSClass
:
qos
.
GetPodQOS
(
pod
),
}
}
podutil
.
DropDisabled
Alpha
Fields
(
&
pod
.
Spec
)
podutil
.
DropDisabledFields
(
&
pod
.
Spec
)
}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
// 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
...
@@ -82,8 +82,8 @@ func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
oldPod
:=
old
.
(
*
api
.
Pod
)
oldPod
:=
old
.
(
*
api
.
Pod
)
newPod
.
Status
=
oldPod
.
Status
newPod
.
Status
=
oldPod
.
Status
podutil
.
DropDisabled
Alpha
Fields
(
&
newPod
.
Spec
)
podutil
.
DropDisabledFields
(
&
newPod
.
Spec
)
podutil
.
DropDisabled
Alpha
Fields
(
&
oldPod
.
Spec
)
podutil
.
DropDisabledFields
(
&
oldPod
.
Spec
)
}
}
// Validate validates a new pod.
// Validate validates a new pod.
...
...
pkg/registry/core/podtemplate/strategy.go
View file @
49028df5
...
@@ -47,7 +47,7 @@ func (podTemplateStrategy) NamespaceScoped() bool {
...
@@ -47,7 +47,7 @@ func (podTemplateStrategy) NamespaceScoped() bool {
func
(
podTemplateStrategy
)
PrepareForCreate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
{
func
(
podTemplateStrategy
)
PrepareForCreate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
{
template
:=
obj
.
(
*
api
.
PodTemplate
)
template
:=
obj
.
(
*
api
.
PodTemplate
)
pod
.
DropDisabled
Alpha
Fields
(
&
template
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
template
.
Template
.
Spec
)
}
}
// Validate validates a new pod template.
// Validate validates a new pod template.
...
@@ -70,8 +70,8 @@ func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
...
@@ -70,8 +70,8 @@ func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
newTemplate
:=
obj
.
(
*
api
.
PodTemplate
)
newTemplate
:=
obj
.
(
*
api
.
PodTemplate
)
oldTemplate
:=
old
.
(
*
api
.
PodTemplate
)
oldTemplate
:=
old
.
(
*
api
.
PodTemplate
)
pod
.
DropDisabled
Alpha
Fields
(
&
newTemplate
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newTemplate
.
Template
.
Spec
)
pod
.
DropDisabled
Alpha
Fields
(
&
oldTemplate
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldTemplate
.
Template
.
Spec
)
}
}
// ValidateUpdate is the default update validation for an end user.
// ValidateUpdate is the default update validation for an end user.
...
...
pkg/registry/core/replicationcontroller/strategy.go
View file @
49028df5
...
@@ -81,7 +81,7 @@ func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
...
@@ -81,7 +81,7 @@ func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
controller
.
Generation
=
1
controller
.
Generation
=
1
if
controller
.
Spec
.
Template
!=
nil
{
if
controller
.
Spec
.
Template
!=
nil
{
pod
.
DropDisabled
Alpha
Fields
(
&
controller
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
controller
.
Spec
.
Template
.
Spec
)
}
}
}
}
...
@@ -93,10 +93,10 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
...
@@ -93,10 +93,10 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
newController
.
Status
=
oldController
.
Status
newController
.
Status
=
oldController
.
Status
if
oldController
.
Spec
.
Template
!=
nil
{
if
oldController
.
Spec
.
Template
!=
nil
{
pod
.
DropDisabled
Alpha
Fields
(
&
oldController
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
oldController
.
Spec
.
Template
.
Spec
)
}
}
if
newController
.
Spec
.
Template
!=
nil
{
if
newController
.
Spec
.
Template
!=
nil
{
pod
.
DropDisabled
Alpha
Fields
(
&
newController
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabledFields
(
&
newController
.
Spec
.
Template
.
Spec
)
}
}
// Any changes to the spec increment the generation number, any changes to the
// Any changes to the spec increment the generation number, any changes to the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment