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
3537eed8
Commit
3537eed8
authored
Apr 26, 2019
by
David McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the generation altering code - validate an update for a PDB by running…
Remove the generation altering code - validate an update for a PDB by running ValidatePodDisruptionBudget only.
parent
5b9e4f1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
119 deletions
+1
-119
validation.go
pkg/apis/policy/validation/validation.go
+0
-11
validation_test.go
pkg/apis/policy/validation/validation_test.go
+0
-105
strategy.go
pkg/registry/policy/poddisruptionbudget/strategy.go
+1
-3
No files found.
pkg/apis/policy/validation/validation.go
View file @
3537eed8
...
...
@@ -41,17 +41,6 @@ func ValidatePodDisruptionBudget(pdb *policy.PodDisruptionBudget) field.ErrorLis
return
allErrs
}
func
ValidatePodDisruptionBudgetUpdate
(
pdb
,
oldPdb
*
policy
.
PodDisruptionBudget
)
field
.
ErrorList
{
restoreGeneration
:=
pdb
.
Generation
pdb
.
Generation
=
oldPdb
.
Generation
allErrs
:=
ValidatePodDisruptionBudgetSpec
(
pdb
.
Spec
,
field
.
NewPath
(
"spec"
))
allErrs
=
append
(
allErrs
,
ValidatePodDisruptionBudgetStatus
(
pdb
.
Status
,
field
.
NewPath
(
"status"
))
...
)
pdb
.
Generation
=
restoreGeneration
return
allErrs
}
func
ValidatePodDisruptionBudgetSpec
(
spec
policy
.
PodDisruptionBudgetSpec
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
...
...
pkg/apis/policy/validation/validation_test.go
View file @
3537eed8
...
...
@@ -122,111 +122,6 @@ func TestValidatePodDisruptionBudgetStatus(t *testing.T) {
}
}
func
TestValidatePodDisruptionBudgetUpdate
(
t
*
testing
.
T
)
{
c1
:=
intstr
.
FromString
(
"10%"
)
c2
:=
intstr
.
FromInt
(
1
)
c3
:=
intstr
.
FromInt
(
2
)
oldPdb
:=
&
policy
.
PodDisruptionBudget
{}
pdb
:=
&
policy
.
PodDisruptionBudget
{}
testCases
:=
[]
struct
{
generations
[]
int64
name
string
specs
[]
policy
.
PodDisruptionBudgetSpec
status
[]
policy
.
PodDisruptionBudgetStatus
ok
bool
}{
{
name
:
"only update status"
,
generations
:
[]
int64
{
int64
(
2
),
int64
(
3
)},
specs
:
[]
policy
.
PodDisruptionBudgetSpec
{
{
MinAvailable
:
&
c1
,
},
{
MinAvailable
:
&
c1
,
},
},
status
:
[]
policy
.
PodDisruptionBudgetStatus
{
{
PodDisruptionsAllowed
:
10
,
CurrentHealthy
:
5
,
ExpectedPods
:
2
,
},
{
PodDisruptionsAllowed
:
8
,
CurrentHealthy
:
5
,
DesiredHealthy
:
3
,
},
},
ok
:
true
,
},
{
name
:
"update pdb spec causing clash"
,
generations
:
[]
int64
{
int64
(
2
),
int64
(
3
)},
specs
:
[]
policy
.
PodDisruptionBudgetSpec
{
{
MaxUnavailable
:
&
c2
,
},
{
MinAvailable
:
&
c1
,
MaxUnavailable
:
&
c3
,
},
},
status
:
[]
policy
.
PodDisruptionBudgetStatus
{
{
PodDisruptionsAllowed
:
10
,
},
{
PodDisruptionsAllowed
:
10
,
},
},
ok
:
false
,
},
{
name
:
"update spec and status"
,
generations
:
[]
int64
{
int64
(
2
),
int64
(
3
)},
specs
:
[]
policy
.
PodDisruptionBudgetSpec
{
{
MaxUnavailable
:
&
c2
,
},
{
MaxUnavailable
:
&
c3
,
},
},
status
:
[]
policy
.
PodDisruptionBudgetStatus
{
{
PodDisruptionsAllowed
:
10
,
CurrentHealthy
:
5
,
ExpectedPods
:
2
,
},
{
PodDisruptionsAllowed
:
8
,
CurrentHealthy
:
5
,
DesiredHealthy
:
3
,
},
},
ok
:
true
,
},
}
for
i
,
tc
:=
range
testCases
{
oldPdb
.
Spec
=
tc
.
specs
[
0
]
oldPdb
.
Generation
=
tc
.
generations
[
0
]
oldPdb
.
Status
=
tc
.
status
[
0
]
pdb
.
Spec
=
tc
.
specs
[
1
]
pdb
.
Generation
=
tc
.
generations
[
1
]
pdb
.
Status
=
tc
.
status
[
1
]
errs
:=
ValidatePodDisruptionBudgetUpdate
(
pdb
,
oldPdb
)
if
tc
.
ok
&&
len
(
errs
)
>
0
{
t
.
Errorf
(
"[%d:%s] unexpected errors: %v"
,
i
,
tc
.
name
,
errs
)
}
else
if
!
tc
.
ok
&&
len
(
errs
)
==
0
{
t
.
Errorf
(
"[%d:%s] expected errors: %v"
,
i
,
tc
.
name
,
errs
)
}
}
}
func
TestValidatePodSecurityPolicy
(
t
*
testing
.
T
)
{
validPSP
:=
func
()
*
policy
.
PodSecurityPolicy
{
return
&
policy
.
PodSecurityPolicy
{
...
...
pkg/registry/policy/poddisruptionbudget/strategy.go
View file @
3537eed8
...
...
@@ -83,9 +83,7 @@ func (podDisruptionBudgetStrategy) AllowCreateOnUpdate() bool {
// ValidateUpdate is the default update validation for an end user.
func
(
podDisruptionBudgetStrategy
)
ValidateUpdate
(
ctx
context
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
validationErrorList
:=
validation
.
ValidatePodDisruptionBudget
(
obj
.
(
*
policy
.
PodDisruptionBudget
))
updateErrorList
:=
validation
.
ValidatePodDisruptionBudgetUpdate
(
obj
.
(
*
policy
.
PodDisruptionBudget
),
old
.
(
*
policy
.
PodDisruptionBudget
))
return
append
(
validationErrorList
,
updateErrorList
...
)
return
validation
.
ValidatePodDisruptionBudget
(
obj
.
(
*
policy
.
PodDisruptionBudget
))
}
// AllowUnconditionalUpdate is the default update policy for PodDisruptionBudget objects. Status update should
...
...
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