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
12dd768b
Commit
12dd768b
authored
Jan 07, 2019
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass pod annotations into DropDisabledFields()
parent
8dbda225
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
75 additions
and
39 deletions
+75
-39
util.go
pkg/api/pod/util.go
+50
-3
util_test.go
pkg/api/pod/util_test.go
+7
-7
strategy.go
pkg/registry/apps/daemonset/strategy.go
+2
-2
strategy.go
pkg/registry/apps/deployment/strategy.go
+2
-2
strategy.go
pkg/registry/apps/replicaset/strategy.go
+2
-2
strategy.go
pkg/registry/apps/statefulset/strategy.go
+2
-2
strategy.go
pkg/registry/batch/cronjob/strategy.go
+2
-2
strategy.go
pkg/registry/batch/job/strategy.go
+2
-2
strategy.go
pkg/registry/core/pod/strategy.go
+2
-2
strategy.go
pkg/registry/core/podtemplate/strategy.go
+2
-2
strategy.go
pkg/registry/core/replicationcontroller/strategy.go
+2
-13
No files found.
pkg/api/pod/util.go
View file @
12dd768b
...
@@ -232,9 +232,56 @@ func UpdatePodCondition(status *api.PodStatus, condition *api.PodCondition) bool
...
@@ -232,9 +232,56 @@ func UpdatePodCondition(status *api.PodStatus, condition *api.PodCondition) bool
return
!
isEqual
return
!
isEqual
}
}
// DropDisabledFields removes disabled fields from the pod spec.
// DropDisabledTemplateFields removes disabled fields from the pod template metadata and 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 PodTemplateSpec
func
DropDisabledFields
(
podSpec
,
oldPodSpec
*
api
.
PodSpec
)
{
func
DropDisabledTemplateFields
(
podTemplate
,
oldPodTemplate
*
api
.
PodTemplateSpec
)
{
var
(
podSpec
*
api
.
PodSpec
podAnnotations
map
[
string
]
string
oldPodSpec
*
api
.
PodSpec
oldPodAnnotations
map
[
string
]
string
)
if
podTemplate
!=
nil
{
podSpec
=
&
podTemplate
.
Spec
podAnnotations
=
podTemplate
.
Annotations
}
if
oldPodTemplate
!=
nil
{
oldPodSpec
=
&
oldPodTemplate
.
Spec
oldPodAnnotations
=
oldPodTemplate
.
Annotations
}
dropDisabledFields
(
podSpec
,
podAnnotations
,
oldPodSpec
,
oldPodAnnotations
)
}
// DropDisabledPodFields removes disabled fields from the pod metadata and spec.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a Pod
func
DropDisabledPodFields
(
pod
,
oldPod
*
api
.
Pod
)
{
var
(
podSpec
*
api
.
PodSpec
podAnnotations
map
[
string
]
string
oldPodSpec
*
api
.
PodSpec
oldPodAnnotations
map
[
string
]
string
)
if
pod
!=
nil
{
podSpec
=
&
pod
.
Spec
podAnnotations
=
pod
.
Annotations
}
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodAnnotations
=
oldPod
.
Annotations
}
dropDisabledFields
(
podSpec
,
podAnnotations
,
oldPodSpec
,
oldPodAnnotations
)
}
// dropDisabledFields removes disabled fields from the pod metadata and spec.
func
dropDisabledFields
(
podSpec
*
api
.
PodSpec
,
podAnnotations
map
[
string
]
string
,
oldPodSpec
*
api
.
PodSpec
,
oldPodAnnotations
map
[
string
]
string
,
)
{
// the new spec must always be non-nil
if
podSpec
==
nil
{
podSpec
=
&
api
.
PodSpec
{}
}
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
&&
!
podPriorityInUse
(
oldPodSpec
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodPriority
)
&&
!
podPriorityInUse
(
oldPodSpec
)
{
// Set to nil pod's priority fields if the feature is disabled and the old pod
// Set to nil pod's priority fields if the feature is disabled and the old pod
// does not specify any values for these fields.
// does not specify any values for these fields.
...
...
pkg/api/pod/util_test.go
View file @
12dd768b
...
@@ -375,7 +375,7 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
...
@@ -375,7 +375,7 @@ func TestDropAlphaVolumeDevices(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -469,7 +469,7 @@ func TestDropSubPath(t *testing.T) {
...
@@ -469,7 +469,7 @@ func TestDropSubPath(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -558,7 +558,7 @@ func TestDropRuntimeClass(t *testing.T) {
...
@@ -558,7 +558,7 @@ func TestDropRuntimeClass(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -652,7 +652,7 @@ func TestDropProcMount(t *testing.T) {
...
@@ -652,7 +652,7 @@ func TestDropProcMount(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -768,7 +768,7 @@ func TestDropPodPriority(t *testing.T) {
...
@@ -768,7 +768,7 @@ func TestDropPodPriority(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -878,7 +878,7 @@ func TestDropEmptyDirSizeLimit(t *testing.T) {
...
@@ -878,7 +878,7 @@ func TestDropEmptyDirSizeLimit(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
@@ -1013,7 +1013,7 @@ func TestDropRunAsGroup(t *testing.T) {
...
@@ -1013,7 +1013,7 @@ func TestDropRunAsGroup(t *testing.T) {
if
oldPod
!=
nil
{
if
oldPod
!=
nil
{
oldPodSpec
=
&
oldPod
.
Spec
oldPodSpec
=
&
oldPod
.
Spec
}
}
DropDisabledFields
(
&
newPod
.
Spec
,
oldPodSpec
)
dropDisabledFields
(
&
newPod
.
Spec
,
nil
,
oldPodSpec
,
nil
)
// old pod should never be changed
// old pod should never be changed
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
if
!
reflect
.
DeepEqual
(
oldPod
,
oldPodInfo
.
pod
())
{
...
...
pkg/registry/apps/daemonset/strategy.go
View file @
12dd768b
...
@@ -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
Fields
(
&
daemonSet
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
daemonSet
.
Spec
.
Template
,
nil
)
}
}
// 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,7 +83,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
...
@@ -83,7 +83,7 @@ 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
Fields
(
&
newDaemonSet
.
Spec
.
Template
.
Spec
,
&
oldDaemonSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newDaemonSet
.
Spec
.
Template
,
&
oldDaemonSet
.
Spec
.
Template
)
// 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 @
12dd768b
...
@@ -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
Fields
(
&
deployment
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
deployment
.
Spec
.
Template
,
nil
)
}
}
// Validate validates a new deployment.
// Validate validates a new deployment.
...
@@ -97,7 +97,7 @@ func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime
...
@@ -97,7 +97,7 @@ 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
Fields
(
&
newDeployment
.
Spec
.
Template
.
Spec
,
&
oldDeployment
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newDeployment
.
Spec
.
Template
,
&
oldDeployment
.
Spec
.
Template
)
// 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 @
12dd768b
...
@@ -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
Fields
(
&
rs
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
rs
.
Spec
.
Template
,
nil
)
}
}
// 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,7 +90,7 @@ func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
...
@@ -90,7 +90,7 @@ 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
Fields
(
&
newRS
.
Spec
.
Template
.
Spec
,
&
oldRS
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newRS
.
Spec
.
Template
,
&
oldRS
.
Spec
.
Template
)
// 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 @
12dd768b
...
@@ -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
Fields
(
&
statefulSet
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
statefulSet
.
Spec
.
Template
,
nil
)
}
}
// 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,7 +82,7 @@ func (statefulSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
...
@@ -82,7 +82,7 @@ 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
Fields
(
&
newStatefulSet
.
Spec
.
Template
.
Spec
,
&
oldStatefulSet
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newStatefulSet
.
Spec
.
Template
,
&
oldStatefulSet
.
Spec
.
Template
)
// 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 @
12dd768b
...
@@ -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
Fields
(
&
cronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
cronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
,
nil
)
}
}
// 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,7 +77,7 @@ func (cronJobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Ob
...
@@ -77,7 +77,7 @@ 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
Fields
(
&
newCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
,
&
oldCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
,
&
oldCronJob
.
Spec
.
JobTemplate
.
Spec
.
Template
)
}
}
// Validate validates a new scheduled job.
// Validate validates a new scheduled job.
...
...
pkg/registry/batch/job/strategy.go
View file @
12dd768b
...
@@ -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
Fields
(
&
job
.
Spec
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
job
.
Spec
.
Template
,
nil
)
}
}
// 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.
...
@@ -93,7 +93,7 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
...
@@ -93,7 +93,7 @@ func (jobStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
newJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
newJob
.
Spec
.
TTLSecondsAfterFinished
=
nil
}
}
pod
.
DropDisabled
Fields
(
&
newJob
.
Spec
.
Template
.
Spec
,
&
oldJob
.
Spec
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newJob
.
Spec
.
Template
,
&
oldJob
.
Spec
.
Template
)
}
}
// Validate validates a new job.
// Validate validates a new job.
...
...
pkg/registry/core/pod/strategy.go
View file @
12dd768b
...
@@ -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
Fields
(
&
pod
.
Spec
,
nil
)
podutil
.
DropDisabled
PodFields
(
pod
,
nil
)
}
}
// 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,7 +82,7 @@ func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
...
@@ -82,7 +82,7 @@ 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
Fields
(
&
newPod
.
Spec
,
&
oldPod
.
Spec
)
podutil
.
DropDisabled
PodFields
(
newPod
,
oldPod
)
}
}
// Validate validates a new pod.
// Validate validates a new pod.
...
...
pkg/registry/core/podtemplate/strategy.go
View file @
12dd768b
...
@@ -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
Fields
(
&
template
.
Template
.
Spec
,
nil
)
pod
.
DropDisabled
TemplateFields
(
&
template
.
Template
,
nil
)
}
}
// Validate validates a new pod template.
// Validate validates a new pod template.
...
@@ -70,7 +70,7 @@ func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
...
@@ -70,7 +70,7 @@ 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
Fields
(
&
newTemplate
.
Template
.
Spec
,
&
oldTemplate
.
Template
.
Spec
)
pod
.
DropDisabled
TemplateFields
(
&
newTemplate
.
Template
,
&
oldTemplate
.
Template
)
}
}
// 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 @
12dd768b
...
@@ -80,9 +80,7 @@ func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
...
@@ -80,9 +80,7 @@ func (rcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
controller
.
Generation
=
1
controller
.
Generation
=
1
if
controller
.
Spec
.
Template
!=
nil
{
pod
.
DropDisabledTemplateFields
(
controller
.
Spec
.
Template
,
nil
)
pod
.
DropDisabledFields
(
&
controller
.
Spec
.
Template
.
Spec
,
nil
)
}
}
}
// 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.
...
@@ -92,16 +90,7 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
...
@@ -92,16 +90,7 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
// update is not allowed to set status
// update is not allowed to set status
newController
.
Status
=
oldController
.
Status
newController
.
Status
=
oldController
.
Status
var
newSpec
,
oldSpec
*
api
.
PodSpec
pod
.
DropDisabledTemplateFields
(
newController
.
Spec
.
Template
,
oldController
.
Spec
.
Template
)
if
oldController
.
Spec
.
Template
!=
nil
{
oldSpec
=
&
oldController
.
Spec
.
Template
.
Spec
}
if
newController
.
Spec
.
Template
!=
nil
{
newSpec
=
&
newController
.
Spec
.
Template
.
Spec
}
else
{
newSpec
=
&
api
.
PodSpec
{}
}
pod
.
DropDisabledFields
(
newSpec
,
oldSpec
)
// 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
...
...
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