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
dad0fa07
Commit
dad0fa07
authored
Feb 15, 2018
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename StorageProtection to StorageObjectInUseProtection
parent
237007b6
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
39 additions
and
39 deletions
+39
-39
config-default.sh
cluster/centos/config-default.sh
+1
-1
config-default.sh
cluster/gce/config-default.sh
+1
-1
core.go
cmd/kube-controller-manager/app/core.go
+2
-2
index.go
pkg/controller/volume/persistentvolume/index.go
+1
-1
index_test.go
pkg/controller/volume/persistentvolume/index_test.go
+14
-14
pv_controller.go
pkg/controller/volume/persistentvolume/pv_controller.go
+1
-1
kube_features.go
pkg/features/kube_features.go
+2
-2
BUILD
pkg/kubeapiserver/options/BUILD
+1
-1
plugins.go
pkg/kubeapiserver/options/plugins.go
+3
-3
desired_state_of_world_populator.go
...lumemanager/populator/desired_state_of_world_populator.go
+1
-1
BUILD
plugin/BUILD
+1
-1
BUILD
.../pkg/admission/storage/storageobjectinuseprotection/BUILD
+1
-1
admission.go
...mission/storage/storageobjectinuseprotection/admission.go
+3
-3
admission_test.go
...on/storage/storageobjectinuseprotection/admission_test.go
+3
-3
controller_policy.go
...auth/authorizer/rbac/bootstrappolicy/controller_policy.go
+2
-2
pv_protection.go
test/e2e/storage/pv_protection.go
+1
-1
pvc_protection.go
test/e2e/storage/pvc_protection.go
+1
-1
No files found.
cluster/centos/config-default.sh
View file @
dad0fa07
...
@@ -124,7 +124,7 @@ export FLANNEL_NET=${FLANNEL_NET:-"172.16.0.0/16"}
...
@@ -124,7 +124,7 @@ export FLANNEL_NET=${FLANNEL_NET:-"172.16.0.0/16"}
# modification is overwritten.
# modification is overwritten.
# If we included ResourceQuota, we should keep it at the end of the list to
# If we included ResourceQuota, we should keep it at the end of the list to
# prevent incrementing quota usage prematurely.
# prevent incrementing quota usage prematurely.
export
ADMISSION_CONTROL
=
${
ADMISSION_CONTROL
:-
"Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeClaimResize,DefaultTolerationSeconds,Priority,StorageProtection,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
}
export
ADMISSION_CONTROL
=
${
ADMISSION_CONTROL
:-
"Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeClaimResize,DefaultTolerationSeconds,Priority,Storage
ObjectInUse
Protection,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
}
# Extra options to set on the Docker command line.
# Extra options to set on the Docker command line.
# This is useful for setting --insecure-registry for local registries.
# This is useful for setting --insecure-registry for local registries.
...
...
cluster/gce/config-default.sh
View file @
dad0fa07
...
@@ -295,7 +295,7 @@ if [[ -n "${GCE_GLBC_IMAGE:-}" ]]; then
...
@@ -295,7 +295,7 @@ if [[ -n "${GCE_GLBC_IMAGE:-}" ]]; then
fi
fi
# Admission Controllers to invoke prior to persisting objects in cluster
# Admission Controllers to invoke prior to persisting objects in cluster
ADMISSION_CONTROL
=
Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,PersistentVolumeClaimResize,DefaultTolerationSeconds,NodeRestriction,Priority,StorageProtection
ADMISSION_CONTROL
=
Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,PersistentVolumeClaimResize,DefaultTolerationSeconds,NodeRestriction,Priority,Storage
ObjectInUse
Protection
if
[[
"
${
ENABLE_POD_SECURITY_POLICY
:-}
"
==
"true"
]]
;
then
if
[[
"
${
ENABLE_POD_SECURITY_POLICY
:-}
"
==
"true"
]]
;
then
ADMISSION_CONTROL
=
"
${
ADMISSION_CONTROL
}
,PodSecurityPolicy"
ADMISSION_CONTROL
=
"
${
ADMISSION_CONTROL
}
,PodSecurityPolicy"
...
...
cmd/kube-controller-manager/app/core.go
View file @
dad0fa07
...
@@ -395,7 +395,7 @@ func startGarbageCollectorController(ctx ControllerContext) (bool, error) {
...
@@ -395,7 +395,7 @@ func startGarbageCollectorController(ctx ControllerContext) (bool, error) {
}
}
func
startPVCProtectionController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
func
startPVCProtectionController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
go
pvcprotection
.
NewPVCProtectionController
(
go
pvcprotection
.
NewPVCProtectionController
(
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumeClaims
(),
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
Pods
(),
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
Pods
(),
...
@@ -407,7 +407,7 @@ func startPVCProtectionController(ctx ControllerContext) (bool, error) {
...
@@ -407,7 +407,7 @@ func startPVCProtectionController(ctx ControllerContext) (bool, error) {
}
}
func
startPVProtectionController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
func
startPVProtectionController
(
ctx
ControllerContext
)
(
bool
,
error
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
go
pvprotection
.
NewPVProtectionController
(
go
pvprotection
.
NewPVProtectionController
(
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
ctx
.
InformerFactory
.
Core
()
.
V1
()
.
PersistentVolumes
(),
ctx
.
ClientBuilder
.
ClientOrDie
(
"pv-protection-controller"
),
ctx
.
ClientBuilder
.
ClientOrDie
(
"pv-protection-controller"
),
...
...
pkg/controller/volume/persistentvolume/index.go
View file @
dad0fa07
...
@@ -170,7 +170,7 @@ func findMatchingVolume(
...
@@ -170,7 +170,7 @@ func findMatchingVolume(
}
}
// check if PV's DeletionTimeStamp is set, if so, skip this volume.
// check if PV's DeletionTimeStamp is set, if so, skip this volume.
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
if
volume
.
ObjectMeta
.
DeletionTimestamp
!=
nil
{
if
volume
.
ObjectMeta
.
DeletionTimestamp
!=
nil
{
continue
continue
}
}
...
...
pkg/controller/volume/persistentvolume/index_test.go
View file @
dad0fa07
...
@@ -1043,7 +1043,7 @@ func TestAlphaFilteringVolumeModes(t *testing.T) {
...
@@ -1043,7 +1043,7 @@ func TestAlphaFilteringVolumeModes(t *testing.T) {
toggleFeature
(
false
,
"BlockVolume"
,
t
)
toggleFeature
(
false
,
"BlockVolume"
,
t
)
}
}
func
TestAlphaStorageProtectionFiltering
(
t
*
testing
.
T
)
{
func
TestAlphaStorage
ObjectInUse
ProtectionFiltering
(
t
*
testing
.
T
)
{
pv
:=
&
v1
.
PersistentVolume
{
pv
:=
&
v1
.
PersistentVolume
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"pv1"
,
Name
:
"pv1"
,
...
@@ -1075,36 +1075,36 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
...
@@ -1075,36 +1075,36 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
isExpectedMatch
bool
isExpectedMatch
bool
vol
*
v1
.
PersistentVolume
vol
*
v1
.
PersistentVolume
pvc
*
v1
.
PersistentVolumeClaim
pvc
*
v1
.
PersistentVolumeClaim
enableStorageProtection
bool
enableStorage
ObjectInUse
Protection
bool
}{
}{
"feature enabled - pv deletionTimeStamp not set"
:
{
"feature enabled - pv deletionTimeStamp not set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
pv
,
vol
:
pv
,
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
true
,
enableStorage
ObjectInUse
Protection
:
true
,
},
},
"feature enabled - pv deletionTimeStamp set"
:
{
"feature enabled - pv deletionTimeStamp set"
:
{
isExpectedMatch
:
false
,
isExpectedMatch
:
false
,
vol
:
pvToDelete
,
vol
:
pvToDelete
,
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
true
,
enableStorage
ObjectInUse
Protection
:
true
,
},
},
"feature disabled - pv deletionTimeStamp not set"
:
{
"feature disabled - pv deletionTimeStamp not set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
pv
,
vol
:
pv
,
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
false
,
enableStorage
ObjectInUse
Protection
:
false
,
},
},
"feature disabled - pv deletionTimeStamp set"
:
{
"feature disabled - pv deletionTimeStamp set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
pvToDelete
,
vol
:
pvToDelete
,
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
false
,
enableStorage
ObjectInUse
Protection
:
false
,
},
},
}
}
for
name
,
testCase
:=
range
satisfyingTestCases
{
for
name
,
testCase
:=
range
satisfyingTestCases
{
toggleFeature
(
testCase
.
enableStorage
Protection
,
"Storag
eProtection"
,
t
)
toggleFeature
(
testCase
.
enableStorage
ObjectInUseProtection
,
"StorageObjectInUs
eProtection"
,
t
)
err
:=
checkVolumeSatisfyClaim
(
testCase
.
vol
,
testCase
.
pvc
)
err
:=
checkVolumeSatisfyClaim
(
testCase
.
vol
,
testCase
.
pvc
)
// expected to match but got an error
// expected to match but got an error
if
err
!=
nil
&&
testCase
.
isExpectedMatch
{
if
err
!=
nil
&&
testCase
.
isExpectedMatch
{
...
@@ -1121,35 +1121,35 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
...
@@ -1121,35 +1121,35 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
isExpectedMatch
bool
isExpectedMatch
bool
vol
persistentVolumeOrderedIndex
vol
persistentVolumeOrderedIndex
pvc
*
v1
.
PersistentVolumeClaim
pvc
*
v1
.
PersistentVolumeClaim
enableStorageProtection
bool
enableStorage
ObjectInUse
Protection
bool
}{
}{
"feature enabled - pv deletionTimeStamp not set"
:
{
"feature enabled - pv deletionTimeStamp not set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
createTestVolOrderedIndex
(
pv
),
vol
:
createTestVolOrderedIndex
(
pv
),
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
true
,
enableStorage
ObjectInUse
Protection
:
true
,
},
},
"feature enabled - pv deletionTimeStamp set"
:
{
"feature enabled - pv deletionTimeStamp set"
:
{
isExpectedMatch
:
false
,
isExpectedMatch
:
false
,
vol
:
createTestVolOrderedIndex
(
pvToDelete
),
vol
:
createTestVolOrderedIndex
(
pvToDelete
),
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
true
,
enableStorage
ObjectInUse
Protection
:
true
,
},
},
"feature disabled - pv deletionTimeStamp not set"
:
{
"feature disabled - pv deletionTimeStamp not set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
createTestVolOrderedIndex
(
pv
),
vol
:
createTestVolOrderedIndex
(
pv
),
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
false
,
enableStorage
ObjectInUse
Protection
:
false
,
},
},
"feature disabled - pv deletionTimeStamp set"
:
{
"feature disabled - pv deletionTimeStamp set"
:
{
isExpectedMatch
:
true
,
isExpectedMatch
:
true
,
vol
:
createTestVolOrderedIndex
(
pvToDelete
),
vol
:
createTestVolOrderedIndex
(
pvToDelete
),
pvc
:
pvc
,
pvc
:
pvc
,
enableStorageProtection
:
false
,
enableStorage
ObjectInUse
Protection
:
false
,
},
},
}
}
for
name
,
testCase
:=
range
filteringTestCases
{
for
name
,
testCase
:=
range
filteringTestCases
{
toggleFeature
(
testCase
.
enableStorage
Protection
,
"Storag
eProtection"
,
t
)
toggleFeature
(
testCase
.
enableStorage
ObjectInUseProtection
,
"StorageObjectInUs
eProtection"
,
t
)
pvmatch
,
err
:=
testCase
.
vol
.
findBestMatchForClaim
(
testCase
.
pvc
,
false
)
pvmatch
,
err
:=
testCase
.
vol
.
findBestMatchForClaim
(
testCase
.
pvc
,
false
)
// expected to match but either got an error or no returned pvmatch
// expected to match but either got an error or no returned pvmatch
if
pvmatch
==
nil
&&
testCase
.
isExpectedMatch
{
if
pvmatch
==
nil
&&
testCase
.
isExpectedMatch
{
...
@@ -1168,7 +1168,7 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
...
@@ -1168,7 +1168,7 @@ func TestAlphaStorageProtectionFiltering(t *testing.T) {
}
}
// make sure feature gate is turned off
// make sure feature gate is turned off
toggleFeature
(
false
,
"StorageProtection"
,
t
)
toggleFeature
(
false
,
"Storage
ObjectInUse
Protection"
,
t
)
}
}
func
TestFindingPreboundVolumes
(
t
*
testing
.
T
)
{
func
TestFindingPreboundVolumes
(
t
*
testing
.
T
)
{
...
...
pkg/controller/volume/persistentvolume/pv_controller.go
View file @
dad0fa07
...
@@ -240,7 +240,7 @@ func checkVolumeSatisfyClaim(volume *v1.PersistentVolume, claim *v1.PersistentVo
...
@@ -240,7 +240,7 @@ func checkVolumeSatisfyClaim(volume *v1.PersistentVolume, claim *v1.PersistentVo
requestedSize
:=
requestedQty
.
Value
()
requestedSize
:=
requestedQty
.
Value
()
// check if PV's DeletionTimeStamp is set, if so, return error.
// check if PV's DeletionTimeStamp is set, if so, return error.
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
if
volume
.
ObjectMeta
.
DeletionTimestamp
!=
nil
{
if
volume
.
ObjectMeta
.
DeletionTimestamp
!=
nil
{
return
fmt
.
Errorf
(
"the volume is marked for deletion"
)
return
fmt
.
Errorf
(
"the volume is marked for deletion"
)
}
}
...
...
pkg/features/kube_features.go
View file @
dad0fa07
...
@@ -206,7 +206,7 @@ const (
...
@@ -206,7 +206,7 @@ const (
// alpha: v1.9
// alpha: v1.9
//
//
// Postpone deletion of a PV or a PVC when they are being used
// Postpone deletion of a PV or a PVC when they are being used
Storage
Protection
utilfeature
.
Feature
=
"Storag
eProtection"
Storage
ObjectInUseProtection
utilfeature
.
Feature
=
"StorageObjectInUs
eProtection"
// owner: @aveshagarwal
// owner: @aveshagarwal
// alpha: v1.9
// alpha: v1.9
...
@@ -280,7 +280,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
...
@@ -280,7 +280,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
CSIPersistentVolume
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
CSIPersistentVolume
:
{
Default
:
true
,
PreRelease
:
utilfeature
.
Beta
},
CustomPodDNS
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
CustomPodDNS
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
BlockVolume
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
BlockVolume
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
Storage
Protection
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
Storage
ObjectInUseProtection
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
ResourceLimitsPriorityFunction
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
ResourceLimitsPriorityFunction
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
SupportIPVSProxyMode
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Beta
},
SupportIPVSProxyMode
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Beta
},
SupportPodPidsLimit
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
SupportPodPidsLimit
:
{
Default
:
false
,
PreRelease
:
utilfeature
.
Alpha
},
...
...
pkg/kubeapiserver/options/BUILD
View file @
dad0fa07
...
@@ -52,7 +52,7 @@ go_library(
...
@@ -52,7 +52,7 @@ go_library(
"//plugin/pkg/admission/security/podsecuritypolicy:go_default_library",
"//plugin/pkg/admission/security/podsecuritypolicy:go_default_library",
"//plugin/pkg/admission/securitycontext/scdeny:go_default_library",
"//plugin/pkg/admission/securitycontext/scdeny:go_default_library",
"//plugin/pkg/admission/serviceaccount:go_default_library",
"//plugin/pkg/admission/serviceaccount:go_default_library",
"//plugin/pkg/admission/storage/storageprotection:go_default_library",
"//plugin/pkg/admission/storage/storage
objectinuse
protection:go_default_library",
"//plugin/pkg/admission/storageclass/setdefault:go_default_library",
"//plugin/pkg/admission/storageclass/setdefault:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
...
...
pkg/kubeapiserver/options/plugins.go
View file @
dad0fa07
...
@@ -49,7 +49,7 @@ import (
...
@@ -49,7 +49,7 @@ import (
"k8s.io/kubernetes/plugin/pkg/admission/security/podsecuritypolicy"
"k8s.io/kubernetes/plugin/pkg/admission/security/podsecuritypolicy"
"k8s.io/kubernetes/plugin/pkg/admission/securitycontext/scdeny"
"k8s.io/kubernetes/plugin/pkg/admission/securitycontext/scdeny"
"k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
"k8s.io/kubernetes/plugin/pkg/admission/serviceaccount"
"k8s.io/kubernetes/plugin/pkg/admission/storage/storageprotection"
"k8s.io/kubernetes/plugin/pkg/admission/storage/storage
objectinuse
protection"
"k8s.io/kubernetes/plugin/pkg/admission/storageclass/setdefault"
"k8s.io/kubernetes/plugin/pkg/admission/storageclass/setdefault"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
...
@@ -86,7 +86,7 @@ var AllOrderedPlugins = []string{
...
@@ -86,7 +86,7 @@ var AllOrderedPlugins = []string{
extendedresourcetoleration
.
PluginName
,
// ExtendedResourceToleration
extendedresourcetoleration
.
PluginName
,
// ExtendedResourceToleration
label
.
PluginName
,
// PersistentVolumeLabel
label
.
PluginName
,
// PersistentVolumeLabel
setdefault
.
PluginName
,
// DefaultStorageClass
setdefault
.
PluginName
,
// DefaultStorageClass
storage
protection
.
PluginName
,
// Storag
eProtection
storage
objectinuseprotection
.
PluginName
,
// StorageObjectInUs
eProtection
gc
.
PluginName
,
// OwnerReferencesPermissionEnforcement
gc
.
PluginName
,
// OwnerReferencesPermissionEnforcement
resize
.
PluginName
,
// PersistentVolumeClaimResize
resize
.
PluginName
,
// PersistentVolumeClaimResize
mutatingwebhook
.
PluginName
,
// MutatingAdmissionWebhook
mutatingwebhook
.
PluginName
,
// MutatingAdmissionWebhook
...
@@ -125,7 +125,7 @@ func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
...
@@ -125,7 +125,7 @@ func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
serviceaccount
.
Register
(
plugins
)
serviceaccount
.
Register
(
plugins
)
setdefault
.
Register
(
plugins
)
setdefault
.
Register
(
plugins
)
resize
.
Register
(
plugins
)
resize
.
Register
(
plugins
)
storageprotection
.
Register
(
plugins
)
storage
objectinuse
protection
.
Register
(
plugins
)
}
}
// DefaultOffAdmissionPlugins get admission plugins off by default for kube-apiserver.
// DefaultOffAdmissionPlugins get admission plugins off by default for kube-apiserver.
...
...
pkg/kubelet/volumemanager/populator/desired_state_of_world_populator.go
View file @
dad0fa07
...
@@ -441,7 +441,7 @@ func (dswp *desiredStateOfWorldPopulator) getPVCExtractPV(
...
@@ -441,7 +441,7 @@ func (dswp *desiredStateOfWorldPopulator) getPVCExtractPV(
err
)
err
)
}
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
// Pods that uses a PVC that is being deleted must not be started.
// Pods that uses a PVC that is being deleted must not be started.
//
//
// In case an old kubelet is running without this check or some kubelets
// In case an old kubelet is running without this check or some kubelets
...
...
plugin/BUILD
View file @
dad0fa07
...
@@ -36,7 +36,7 @@ filegroup(
...
@@ -36,7 +36,7 @@ filegroup(
"//plugin/pkg/admission/security:all-srcs",
"//plugin/pkg/admission/security:all-srcs",
"//plugin/pkg/admission/securitycontext/scdeny:all-srcs",
"//plugin/pkg/admission/securitycontext/scdeny:all-srcs",
"//plugin/pkg/admission/serviceaccount:all-srcs",
"//plugin/pkg/admission/serviceaccount:all-srcs",
"//plugin/pkg/admission/storage/storageprotection:all-srcs",
"//plugin/pkg/admission/storage/storage
objectinuse
protection:all-srcs",
"//plugin/pkg/admission/storageclass/setdefault:all-srcs",
"//plugin/pkg/admission/storageclass/setdefault:all-srcs",
"//plugin/pkg/auth:all-srcs",
"//plugin/pkg/auth:all-srcs",
],
],
...
...
plugin/pkg/admission/storage/storageprotection/BUILD
→
plugin/pkg/admission/storage/storage
objectinuse
protection/BUILD
View file @
dad0fa07
...
@@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
...
@@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
go_library(
name = "go_default_library",
name = "go_default_library",
srcs = ["admission.go"],
srcs = ["admission.go"],
importpath = "k8s.io/kubernetes/plugin/pkg/admission/storage/storageprotection",
importpath = "k8s.io/kubernetes/plugin/pkg/admission/storage/storage
objectinuse
protection",
visibility = ["//visibility:public"],
visibility = ["//visibility:public"],
deps = [
deps = [
"//pkg/apis/core:go_default_library",
"//pkg/apis/core:go_default_library",
...
...
plugin/pkg/admission/storage/storageprotection/admission.go
→
plugin/pkg/admission/storage/storage
objectinuse
protection/admission.go
View file @
dad0fa07
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
storageprotection
package
storage
objectinuse
protection
import
(
import
(
"fmt"
"fmt"
...
@@ -34,7 +34,7 @@ import (
...
@@ -34,7 +34,7 @@ import (
const
(
const
(
// PluginName is the name of this admission controller plugin
// PluginName is the name of this admission controller plugin
PluginName
=
"StorageProtection"
PluginName
=
"Storage
ObjectInUse
Protection"
)
)
// Register registers a plugin
// Register registers a plugin
...
@@ -95,7 +95,7 @@ var (
...
@@ -95,7 +95,7 @@ var (
// This prevents users from deleting a PVC that's used by a running pod.
// This prevents users from deleting a PVC that's used by a running pod.
// This also prevents admin from deleting a PV that's bound by a PVC
// This also prevents admin from deleting a PV that's bound by a PVC
func
(
c
*
storageProtectionPlugin
)
Admit
(
a
admission
.
Attributes
)
error
{
func
(
c
*
storageProtectionPlugin
)
Admit
(
a
admission
.
Attributes
)
error
{
if
!
feature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
!
feature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
return
nil
return
nil
}
}
...
...
plugin/pkg/admission/storage/storageprotection/admission_test.go
→
plugin/pkg/admission/storage/storage
objectinuse
protection/admission_test.go
View file @
dad0fa07
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
storageprotection
package
storage
objectinuse
protection
import
(
import
(
"fmt"
"fmt"
...
@@ -122,7 +122,7 @@ func TestAdmit(t *testing.T) {
...
@@ -122,7 +122,7 @@ func TestAdmit(t *testing.T) {
ctrl
.
SetInternalKubeInformerFactory
(
informerFactory
)
ctrl
.
SetInternalKubeInformerFactory
(
informerFactory
)
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
feature
.
DefaultFeatureGate
.
Set
(
fmt
.
Sprintf
(
"StorageProtection=%v"
,
test
.
featureEnabled
))
feature
.
DefaultFeatureGate
.
Set
(
fmt
.
Sprintf
(
"Storage
ObjectInUse
Protection=%v"
,
test
.
featureEnabled
))
obj
:=
test
.
object
.
DeepCopyObject
()
obj
:=
test
.
object
.
DeepCopyObject
()
attrs
:=
admission
.
NewAttributesRecord
(
attrs
:=
admission
.
NewAttributesRecord
(
obj
,
// new object
obj
,
// new object
...
@@ -147,5 +147,5 @@ func TestAdmit(t *testing.T) {
...
@@ -147,5 +147,5 @@ func TestAdmit(t *testing.T) {
// Disable the feature for rest of the tests.
// Disable the feature for rest of the tests.
// TODO: remove after alpha
// TODO: remove after alpha
feature
.
DefaultFeatureGate
.
Set
(
"StorageProtection=false"
)
feature
.
DefaultFeatureGate
.
Set
(
"Storage
ObjectInUse
Protection=false"
)
}
}
plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go
View file @
dad0fa07
...
@@ -324,7 +324,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) {
...
@@ -324,7 +324,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) {
eventsRule
(),
eventsRule
(),
},
},
})
})
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbac
.
ClusterRole
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbac
.
ClusterRole
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"pvc-protection-controller"
},
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"pvc-protection-controller"
},
Rules
:
[]
rbac
.
PolicyRule
{
Rules
:
[]
rbac
.
PolicyRule
{
...
@@ -334,7 +334,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) {
...
@@ -334,7 +334,7 @@ func buildControllerRoles() ([]rbac.ClusterRole, []rbac.ClusterRoleBinding) {
},
},
})
})
}
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
StorageProtection
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
Storage
ObjectInUse
Protection
)
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbac
.
ClusterRole
{
addControllerRole
(
&
controllerRoles
,
&
controllerRoleBindings
,
rbac
.
ClusterRole
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"pv-protection-controller"
},
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
saRolePrefix
+
"pv-protection-controller"
},
Rules
:
[]
rbac
.
PolicyRule
{
Rules
:
[]
rbac
.
PolicyRule
{
...
...
test/e2e/storage/pv_protection.go
View file @
dad0fa07
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
"k8s.io/kubernetes/test/e2e/storage/utils"
"k8s.io/kubernetes/test/e2e/storage/utils"
)
)
var
_
=
utils
.
SIGDescribe
(
"PV Protection [Feature:StorageProtection]"
,
func
()
{
var
_
=
utils
.
SIGDescribe
(
"PV Protection [Feature:Storage
ObjectInUse
Protection]"
,
func
()
{
var
(
var
(
client
clientset
.
Interface
client
clientset
.
Interface
nameSpace
string
nameSpace
string
...
...
test/e2e/storage/pvc_protection.go
View file @
dad0fa07
...
@@ -29,7 +29,7 @@ import (
...
@@ -29,7 +29,7 @@ import (
"k8s.io/kubernetes/test/e2e/storage/utils"
"k8s.io/kubernetes/test/e2e/storage/utils"
)
)
var
_
=
utils
.
SIGDescribe
(
"PVC Protection [Feature:StorageProtection]"
,
func
()
{
var
_
=
utils
.
SIGDescribe
(
"PVC Protection [Feature:Storage
ObjectInUse
Protection]"
,
func
()
{
var
(
var
(
client
clientset
.
Interface
client
clientset
.
Interface
nameSpace
string
nameSpace
string
...
...
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