Commit 4b8050e3 authored by Tim Allclair's avatar Tim Allclair

Address @thockin feedback

parent 87164e0b
......@@ -259,8 +259,8 @@ func DropDisabledAlphaFields(podSpec *api.PodSpec) {
DropDisabledRunAsGroupField(podSpec)
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) && podSpec.RuntimeClassName != "" {
podSpec.RuntimeClassName = ""
if !utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) && podSpec.RuntimeClassName != nil {
podSpec.RuntimeClassName = nil
}
}
......
......@@ -2571,12 +2571,14 @@ type PodSpec struct {
// More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md
// +optional
ReadinessGates []PodReadinessGate
// RuntimeClassName refers to a RuntimeClass object with the same name, which should be used to
// run this pod. If no RuntimeClass resource matches the named class, the pod will not be run.
// RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used
// to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run.
// If unset or empty, the "legacy" RuntimeClass will be used, which is an implicit class with an
// empty definition that uses the default runtime handler.
// More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md
// This is an alpha feature and may change in the future.
// +optional
RuntimeClassName string
RuntimeClassName *string
}
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the
......
......@@ -259,7 +259,13 @@ var ValidatePriorityClassName = apimachineryvalidation.NameIsDNSSubdomain
// ValidateRuntimeClassName can be used to check whether the given RuntimeClass name is valid.
// Prefix indicates this name will be used as part of generation, in which case
// trailing dashes are allowed.
var ValidateRuntimeClassName = apimachineryvalidation.NameIsDNSSubdomain
func ValidateRuntimeClassName(name string, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
for _, msg := range apimachineryvalidation.NameIsDNSSubdomain(name, false) {
allErrs = append(allErrs, field.Invalid(fldPath, name, msg))
}
return allErrs
}
// Validates that given value is not negative.
func ValidateNonnegativeField(value int64, fldPath *field.Path) field.ErrorList {
......@@ -3004,12 +3010,8 @@ func ValidatePodSpec(spec *core.PodSpec, fldPath *field.Path) field.ErrorList {
}
}
if len(spec.RuntimeClassName) > 0 {
if utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
for _, msg := range ValidateRuntimeClassName(spec.RuntimeClassName, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("runtimeClassName"), spec.RuntimeClassName, msg))
}
}
if spec.RuntimeClassName != nil && utilfeature.DefaultFeatureGate.Enabled(features.RuntimeClass) {
allErrs = append(allErrs, ValidateRuntimeClassName(*spec.RuntimeClassName, fldPath.Child("runtimeClassName"))...)
}
return allErrs
......
......@@ -6171,7 +6171,7 @@ func TestValidatePodSpec(t *testing.T) {
Containers: []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
RuntimeClassName: "valid-sandbox",
RuntimeClassName: utilpointer.StringPtr("valid-sandbox"),
},
}
for i := range successCases {
......@@ -6358,7 +6358,7 @@ func TestValidatePodSpec(t *testing.T) {
Containers: []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
RuntimeClassName: "invalid/sandbox",
RuntimeClassName: utilpointer.StringPtr("invalid/sandbox"),
},
}
for k, v := range failureCases {
......
......@@ -2865,12 +2865,14 @@ type PodSpec struct {
// More info: https://github.com/kubernetes/community/blob/master/keps/sig-network/0007-pod-ready%2B%2B.md
// +optional
ReadinessGates []PodReadinessGate `json:"readinessGates,omitempty" protobuf:"bytes,28,opt,name=readinessGates"`
// RuntimeClassName refers to a RuntimeClass object with the same name, which should be used to
// run this pod. If no RuntimeClass resource matches the named class, the pod will not be run.
// RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used
// to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run.
// If unset or empty, the "legacy" RuntimeClass will be used, which is an implicit class with an
// empty definition that uses the default runtime handler.
// More info: https://github.com/kubernetes/community/blob/master/keps/sig-node/0014-runtime-class.md
// This is an alpha feature and may change in the future.
// +optional
RuntimeClassName string `json:"runtimeClassName,omitempty" protobuf:"bytes,29,opt,name=runtimeClassName"`
RuntimeClassName *string `json:"runtimeClassName,omitempty" protobuf:"bytes,29,opt,name=runtimeClassName"`
}
// HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment