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
52a9edbe
Unverified
Commit
52a9edbe
authored
Dec 18, 2018
by
Kubernetes Prow Robot
Committed by
GitHub
Dec 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72172 from liggitt/drop-disabled-fields
Cleanup of disabled field handling
parents
774ac640
901ddba8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
23 deletions
+33
-23
util.go
pkg/api/persistentvolumeclaim/util.go
+5
-2
util_test.go
pkg/api/persistentvolumeclaim/util_test.go
+3
-3
util.go
pkg/api/podsecuritypolicy/util.go
+8
-2
util_test.go
pkg/api/podsecuritypolicy/util_test.go
+3
-3
util.go
pkg/apis/storage/util/util.go
+6
-2
util_test.go
pkg/apis/storage/util/util_test.go
+2
-2
strategy.go
pkg/registry/core/persistentvolumeclaim/strategy.go
+2
-3
strategy.go
pkg/registry/policy/podsecuritypolicy/strategy.go
+2
-3
strategy.go
pkg/registry/storage/storageclass/strategy.go
+2
-3
No files found.
pkg/api/persistentvolumeclaim/util.go
View file @
52a9edbe
...
...
@@ -22,10 +22,13 @@ import (
"k8s.io/kubernetes/pkg/features"
)
// DropDisabled
Alpha
Fields removes disabled fields from the pvc spec.
// DropDisabledFields removes disabled fields from the pvc spec.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pvc spec.
func
DropDisabled
AlphaFields
(
pvc
Spec
*
core
.
PersistentVolumeClaimSpec
)
{
func
DropDisabled
Fields
(
pvcSpec
,
oldPVC
Spec
*
core
.
PersistentVolumeClaimSpec
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
BlockVolume
)
{
pvcSpec
.
VolumeMode
=
nil
if
oldPVCSpec
!=
nil
{
oldPVCSpec
.
VolumeMode
=
nil
}
}
}
pkg/api/persistentvolumeclaim/util_test.go
View file @
52a9edbe
...
...
@@ -39,7 +39,7 @@ func TestDropAlphaPVCVolumeMode(t *testing.T) {
// Enable alpha feature BlockVolume
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
true
)()
// now test dropping the fields - should not be dropped
DropDisabled
AlphaFields
(
&
pvc
.
Spec
)
DropDisabled
Fields
(
&
pvc
.
Spec
,
nil
)
// check to make sure VolumeDevices is still present
// if featureset is set to true
...
...
@@ -50,11 +50,11 @@ func TestDropAlphaPVCVolumeMode(t *testing.T) {
// Disable alpha feature BlockVolume
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
BlockVolume
,
false
)()
// now test dropping the fields
DropDisabled
AlphaFields
(
&
pvc
.
Spec
)
DropDisabled
Fields
(
&
pvc
.
Spec
,
nil
)
// check to make sure VolumeDevices is nil
// if featureset is set to false
if
pvc
.
Spec
.
VolumeMode
!=
nil
{
t
.
Error
(
"DropDisabled
Alpha
Fields VolumeMode for pvc.Spec failed"
)
t
.
Error
(
"DropDisabledFields VolumeMode for pvc.Spec failed"
)
}
}
pkg/api/podsecuritypolicy/util.go
View file @
52a9edbe
...
...
@@ -22,13 +22,19 @@ import (
"k8s.io/kubernetes/pkg/features"
)
// DropDisabled
Alpha
Fields removes disabled fields from the pod security policy spec.
// DropDisabledFields removes disabled fields from the pod security policy spec.
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a od security policy spec.
func
DropDisabled
AlphaFields
(
psp
Spec
*
policy
.
PodSecurityPolicySpec
)
{
func
DropDisabled
Fields
(
pspSpec
,
oldPSP
Spec
*
policy
.
PodSecurityPolicySpec
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ProcMountType
)
{
pspSpec
.
AllowedProcMountTypes
=
nil
if
oldPSPSpec
!=
nil
{
oldPSPSpec
.
AllowedProcMountTypes
=
nil
}
}
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
RunAsGroup
)
{
pspSpec
.
RunAsGroup
=
nil
if
oldPSPSpec
!=
nil
{
oldPSPSpec
.
RunAsGroup
=
nil
}
}
}
pkg/api/podsecuritypolicy/util_test.go
View file @
52a9edbe
...
...
@@ -38,7 +38,7 @@ func TestDropAlphaProcMountType(t *testing.T) {
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
ProcMountType
,
true
)()
// now test dropping the fields - should not be dropped
DropDisabled
AlphaFields
(
&
psp
.
Spec
)
DropDisabled
Fields
(
&
psp
.
Spec
,
nil
)
// check to make sure AllowedProcMountTypes is still present
// if featureset is set to true
...
...
@@ -52,13 +52,13 @@ func TestDropAlphaProcMountType(t *testing.T) {
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
ProcMountType
,
false
)()
// now test dropping the fields
DropDisabled
AlphaFields
(
&
psp
.
Spec
)
DropDisabled
Fields
(
&
psp
.
Spec
,
nil
)
// check to make sure AllowedProcMountTypes is nil
// if featureset is set to false
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
ProcMountType
)
{
if
psp
.
Spec
.
AllowedProcMountTypes
!=
nil
{
t
.
Error
(
"DropDisabled
Alpha
Fields AllowedProcMountTypes for psp.Spec failed"
)
t
.
Error
(
"DropDisabledFields AllowedProcMountTypes for psp.Spec failed"
)
}
}
}
pkg/apis/storage/util/util.go
View file @
52a9edbe
...
...
@@ -22,10 +22,14 @@ import (
"k8s.io/kubernetes/pkg/features"
)
// DropDisabled
Alpha
Fields removes disabled fields from the StorageClass object.
func
DropDisabled
AlphaFields
(
c
lass
*
storage
.
StorageClass
)
{
// DropDisabledFields removes disabled fields from the StorageClass object.
func
DropDisabled
Fields
(
class
,
oldC
lass
*
storage
.
StorageClass
)
{
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
class
.
VolumeBindingMode
=
nil
class
.
AllowedTopologies
=
nil
if
oldClass
!=
nil
{
oldClass
.
VolumeBindingMode
=
nil
oldClass
.
AllowedTopologies
=
nil
}
}
}
pkg/apis/storage/util/util_test.go
View file @
52a9edbe
...
...
@@ -46,7 +46,7 @@ func TestDropAlphaFields(t *testing.T) {
VolumeBindingMode
:
&
bindingMode
,
AllowedTopologies
:
allowedTopologies
,
}
DropDisabled
AlphaFields
(
class
)
DropDisabled
Fields
(
class
,
nil
)
if
class
.
VolumeBindingMode
!=
nil
{
t
.
Errorf
(
"VolumeBindingMode field didn't get dropped: %+v"
,
class
.
VolumeBindingMode
)
}
...
...
@@ -60,7 +60,7 @@ func TestDropAlphaFields(t *testing.T) {
AllowedTopologies
:
allowedTopologies
,
}
defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
VolumeScheduling
,
true
)()
DropDisabled
AlphaFields
(
class
)
DropDisabled
Fields
(
class
,
nil
)
if
class
.
VolumeBindingMode
!=
&
bindingMode
{
t
.
Errorf
(
"VolumeBindingMode field got unexpectantly modified: %+v"
,
class
.
VolumeBindingMode
)
}
...
...
pkg/registry/core/persistentvolumeclaim/strategy.go
View file @
52a9edbe
...
...
@@ -52,7 +52,7 @@ func (persistentvolumeclaimStrategy) PrepareForCreate(ctx context.Context, obj r
pvc
:=
obj
.
(
*
api
.
PersistentVolumeClaim
)
pvc
.
Status
=
api
.
PersistentVolumeClaimStatus
{}
pvcutil
.
DropDisabled
AlphaFields
(
&
pvc
.
Spec
)
pvcutil
.
DropDisabled
Fields
(
&
pvc
.
Spec
,
nil
)
}
func
(
persistentvolumeclaimStrategy
)
Validate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
field
.
ErrorList
{
...
...
@@ -74,8 +74,7 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(ctx context.Context, obj,
oldPvc
:=
old
.
(
*
api
.
PersistentVolumeClaim
)
newPvc
.
Status
=
oldPvc
.
Status
pvcutil
.
DropDisabledAlphaFields
(
&
newPvc
.
Spec
)
pvcutil
.
DropDisabledAlphaFields
(
&
oldPvc
.
Spec
)
pvcutil
.
DropDisabledFields
(
&
newPvc
.
Spec
,
&
oldPvc
.
Spec
)
}
func
(
persistentvolumeclaimStrategy
)
ValidateUpdate
(
ctx
context
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
...
...
pkg/registry/policy/podsecuritypolicy/strategy.go
View file @
52a9edbe
...
...
@@ -58,15 +58,14 @@ func (strategy) AllowUnconditionalUpdate() bool {
func
(
strategy
)
PrepareForCreate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
{
psp
:=
obj
.
(
*
policy
.
PodSecurityPolicy
)
psputil
.
DropDisabled
AlphaFields
(
&
psp
.
Spec
)
psputil
.
DropDisabled
Fields
(
&
psp
.
Spec
,
nil
)
}
func
(
strategy
)
PrepareForUpdate
(
ctx
context
.
Context
,
obj
,
old
runtime
.
Object
)
{
newPsp
:=
obj
.
(
*
policy
.
PodSecurityPolicy
)
oldPsp
:=
old
.
(
*
policy
.
PodSecurityPolicy
)
psputil
.
DropDisabledAlphaFields
(
&
newPsp
.
Spec
)
psputil
.
DropDisabledAlphaFields
(
&
oldPsp
.
Spec
)
psputil
.
DropDisabledFields
(
&
newPsp
.
Spec
,
&
oldPsp
.
Spec
)
}
func
(
strategy
)
Canonicalize
(
obj
runtime
.
Object
)
{
...
...
pkg/registry/storage/storageclass/strategy.go
View file @
52a9edbe
...
...
@@ -52,7 +52,7 @@ func (storageClassStrategy) PrepareForCreate(ctx context.Context, obj runtime.Ob
class
.
AllowVolumeExpansion
=
nil
}
storageutil
.
DropDisabled
AlphaFields
(
class
)
storageutil
.
DropDisabled
Fields
(
class
,
nil
)
}
func
(
storageClassStrategy
)
Validate
(
ctx
context
.
Context
,
obj
runtime
.
Object
)
field
.
ErrorList
{
...
...
@@ -77,8 +77,7 @@ func (storageClassStrategy) PrepareForUpdate(ctx context.Context, obj, old runti
newClass
.
AllowVolumeExpansion
=
nil
oldClass
.
AllowVolumeExpansion
=
nil
}
storageutil
.
DropDisabledAlphaFields
(
oldClass
)
storageutil
.
DropDisabledAlphaFields
(
newClass
)
storageutil
.
DropDisabledFields
(
oldClass
,
newClass
)
}
func
(
storageClassStrategy
)
ValidateUpdate
(
ctx
context
.
Context
,
obj
,
old
runtime
.
Object
)
field
.
ErrorList
{
...
...
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