Skip to content

Commit

Permalink
Merge pull request #1650 from zimnx/mz/fix-ingress-class-validation-1.11
Browse files Browse the repository at this point in the history
[v1.11] Loosen validation for LoadBalancerClass in NodeServiceTemplate
  • Loading branch information
scylla-operator-bot[bot] authored Dec 20, 2023
2 parents 92763c2 + 196b221 commit 1abde59
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/api/scylla/validation/cluster_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func ValidateNodeService(nodeService *scyllav1.NodeServiceTemplate, fldPath *fie
}

if nodeService.LoadBalancerClass != nil && len(*nodeService.LoadBalancerClass) != 0 {
for _, msg := range apimachineryvalidation.NameIsDNSSubdomain(*nodeService.LoadBalancerClass, false) {
for _, msg := range apimachineryutilvalidation.IsQualifiedName(*nodeService.LoadBalancerClass) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("loadBalancerClass"), *nodeService.LoadBalancerClass, msg))
}
}
Expand Down
20 changes: 18 additions & 2 deletions pkg/api/scylla/validation/cluster_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,25 @@ func TestValidateScyllaCluster(t *testing.T) {
return cluster
}(),
expectedErrorList: field.ErrorList{
&field.Error{Type: field.ErrorTypeInvalid, Field: "spec.exposeOptions.nodeService.loadBalancerClass", BadValue: "-hello", Detail: `a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`},
&field.Error{Type: field.ErrorTypeInvalid, Field: "spec.exposeOptions.nodeService.loadBalancerClass", BadValue: "-hello", Detail: `name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')`},
},
expectedErrorString: `spec.exposeOptions.nodeService.loadBalancerClass: Invalid value: "-hello": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`,
expectedErrorString: `spec.exposeOptions.nodeService.loadBalancerClass: Invalid value: "-hello": name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')`,
},
{
name: "EKS NLB LoadBalancerClass is valid",
cluster: func() *v1.ScyllaCluster {
cluster := validCluster.DeepCopy()
cluster.Spec.ExposeOptions = &v1.ExposeOptions{
NodeService: &v1.NodeServiceTemplate{
Type: v1.NodeServiceTypeLoadBalancer,
LoadBalancerClass: pointer.Ptr("service.k8s.aws/nlb"),
},
}

return cluster
}(),
expectedErrorList: field.ErrorList{},
expectedErrorString: "",
},
{
name: "unsupported type of client broadcast address",
Expand Down

0 comments on commit 1abde59

Please sign in to comment.