RuntimeClass validation and tests

Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
This commit is contained in:
Serguei Bezverkhi
2018-12-19 15:01:28 -05:00
parent 544c49ab03
commit 27a8967555
3 changed files with 103 additions and 5 deletions

View File

@@ -277,11 +277,9 @@ func DropDisabledFields(podSpec, oldPodSpec *api.PodSpec) {
dropDisabledRunAsGroupField(podSpec, oldPodSpec)
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) && !runtimeClassInUse(oldPodSpec) {
// Set RuntimeClassName to nil only if feature is disabled and it is not used
podSpec.RuntimeClassName = nil
if oldPodSpec != nil {
oldPodSpec.RuntimeClassName = nil
}
}
dropDisabledProcMountField(podSpec, oldPodSpec)
@@ -397,3 +395,14 @@ func subpathInUse(podSpec *api.PodSpec) bool {
}
return false
}
// runtimeClassInUse returns true if the pod spec is non-nil and has a RuntimeClassName set
func runtimeClassInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
return false
}
if podSpec.RuntimeClassName != nil {
return true
}
return false
}