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
4601ac76
Commit
4601ac76
authored
Aug 16, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow non-patch-updates to replicas
parent
332edf8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
validation.go
pkg/apis/apps/validation/validation.go
+5
-7
No files found.
pkg/apis/apps/validation/validation.go
View file @
4601ac76
...
...
@@ -99,22 +99,20 @@ func ValidatePetSet(petSet *apps.PetSet) field.ErrorList {
// ValidatePetSetUpdate tests if required fields in the PetSet are set.
func
ValidatePetSetUpdate
(
petSet
,
oldPetSet
*
apps
.
PetSet
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
allErrs
:=
apivalidation
.
ValidateObjectMetaUpdate
(
&
petSet
.
ObjectMeta
,
&
oldPetSet
.
ObjectMeta
,
field
.
NewPath
(
"metadata"
))
// TODO: For now we're taking the safe route and disallowing all updates to spec except for Spec.Replicas.
// Enable on a case by case basis.
restoreReplicas
:=
petSet
.
Spec
.
Replicas
petSet
.
Spec
.
Replicas
=
oldPetSet
.
Spec
.
Replicas
// The generation changes for this update
restoreGeneration
:=
petSet
.
Generation
petSet
.
Generation
=
oldPetSet
.
Generation
if
!
reflect
.
DeepEqual
(
petSet
,
oldPetSet
)
{
if
!
reflect
.
DeepEqual
(
petSet
.
Spec
,
oldPetSet
.
Spec
)
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
"spec"
),
"updates to petset spec for fields other than 'replicas' are forbidden."
))
}
if
!
reflect
.
DeepEqual
(
petSet
.
Status
,
oldPetSet
.
Status
)
{
allErrs
=
append
(
allErrs
,
field
.
Forbidden
(
field
.
NewPath
(
"status"
),
"updates to petset status forbidden."
))
}
petSet
.
Spec
.
Replicas
=
restoreReplicas
petSet
.
Generation
=
restoreGeneration
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateNonnegativeField
(
int64
(
petSet
.
Spec
.
Replicas
),
field
.
NewPath
(
"spec"
,
"replicas"
))
...
)
return
allErrs
}
...
...
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