mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
parent
aee6d10b57
commit
1c9ee74987
@ -3435,9 +3435,11 @@ func validateEndpointAddress(address *api.EndpointAddress, fldPath *field.Path,
|
||||
if len(address.Hostname) > 0 {
|
||||
allErrs = append(allErrs, ValidateDNS1123Label(address.Hostname, fldPath.Child("hostname"))...)
|
||||
}
|
||||
// During endpoint update, validate NodeName is DNS1123 compliant and transition rules allow the update
|
||||
// During endpoint update, verify that NodeName is a DNS subdomain and transition rules allow the update
|
||||
if address.NodeName != nil {
|
||||
allErrs = append(allErrs, ValidateDNS1123Label(*address.NodeName, fldPath.Child("nodeName"))...)
|
||||
for _, msg := range ValidateNodeName(*address.NodeName, false) {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("nodeName"), *address.NodeName, msg))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, validateEpAddrNodeNameTransition(address, ipToNodeName, fldPath.Child("nodeName"))...)
|
||||
if len(allErrs) > 0 {
|
||||
|
@ -8023,11 +8023,19 @@ func TestEndpointAddressNodeNameUpdateRestrictions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEndpointAddressNodeNameInvalidDNS1123(t *testing.T) {
|
||||
func TestEndpointAddressNodeNameInvalidDNSSubdomain(t *testing.T) {
|
||||
// Check NodeName DNS validation
|
||||
endpoint := newNodeNameEndpoint("illegal.nodename")
|
||||
endpoint := newNodeNameEndpoint("illegal*.nodename")
|
||||
errList := ValidateEndpoints(endpoint)
|
||||
if len(errList) == 0 {
|
||||
t.Error("Endpoint should reject invalid NodeName")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEndpointAddressNodeNameCanBeAnIPAddress(t *testing.T) {
|
||||
endpoint := newNodeNameEndpoint("10.10.1.1")
|
||||
errList := ValidateEndpoints(endpoint)
|
||||
if len(errList) != 0 {
|
||||
t.Error("Endpoint should accept a NodeName that is an IP address")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user