Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1alpha1/backend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type UnixSocket struct {
// Path defines the unix domain socket path of the backend endpoint.
// The path length must not exceed 108 characters.
//
// +kubebuilder:validation:MaxLength=108
// +kubebuilder:validation:XValidation:rule="size(self) <= 108",message="unix domain socket path must not exceed 108 characters"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prev implement cause unexpected error:

The Backend "backend-unix" is invalid:
* spec.endpoints[0].unix.path: Too long: may not be more than 108 bytes
* <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation

Path string `json:"path"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ spec:
description: |-
Path defines the unix domain socket path of the backend endpoint.
The path length must not exceed 108 characters.
maxLength: 108
type: string
x-kubernetes-validations:
- message: unix domain socket path must not exceed 108 characters
rule: size(self) <= 108
required:
- path
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ spec:
description: |-
Path defines the unix domain socket path of the backend endpoint.
The path length must not exceed 108 characters.
maxLength: 108
type: string
x-kubernetes-validations:
- message: unix domain socket path must not exceed 108 characters
rule: size(self) <= 108
required:
- path
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,21 @@ xdsIR:
port: 10443
routes:
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: envoy-gateway
name: httproute/envoy-gateway/httproute-1/rule/0
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
metadata:
kind: Service
name: service-1
namespace: envoy-gateway
sectionName: "8080"
name: httproute/envoy-gateway/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,21 @@ xdsIR:
port: 10443
routes:
- destination:
metadata:
kind: HTTPRoute
name: httproute-1
namespace: envoy-gateway
name: httproute/envoy-gateway/httproute-1/rule/0
settings:
- addressType: IP
endpoints:
- host: 7.7.7.7
port: 8080
metadata:
kind: Service
name: service-1
namespace: envoy-gateway
sectionName: "8080"
name: httproute/envoy-gateway/httproute-1/rule/0/backend/0
protocol: HTTP
weight: 1
Expand Down
3 changes: 2 additions & 1 deletion test/cel-validation/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ func TestBackend(t *testing.T) {
desc: "Invalid Unix socket path length",
mutate: func(backend *egv1a1.Backend) {
backend.Spec = egv1a1.BackendSpec{
Type: ptr.To(egv1a1.BackendTypeEndpoints),
AppProtocols: []egv1a1.AppProtocolType{egv1a1.AppProtocolTypeH2C},
Endpoints: []egv1a1.BackendEndpoint{
{
Expand All @@ -322,7 +323,7 @@ func TestBackend(t *testing.T) {
},
}
},
wantErrors: []string{"spec.endpoints[0].unix.path: Too long: may not be more than 108 bytes"},
wantErrors: []string{`spec.endpoints[0].unix.path: Invalid value: "string": unix domain socket path must not exceed 108 characters`},
},
}

Expand Down
4 changes: 3 additions & 1 deletion test/helm/gateway-crds-helm/all.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17434,8 +17434,10 @@ spec:
description: |-
Path defines the unix domain socket path of the backend endpoint.
The path length must not exceed 108 characters.
maxLength: 108
type: string
x-kubernetes-validations:
- message: unix domain socket path must not exceed 108 characters
rule: size(self) <= 108
required:
- path
type: object
Expand Down
4 changes: 3 additions & 1 deletion test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ spec:
description: |-
Path defines the unix domain socket path of the backend endpoint.
The path length must not exceed 108 characters.
maxLength: 108
type: string
x-kubernetes-validations:
- message: unix domain socket path must not exceed 108 characters
rule: size(self) <= 108
required:
- path
type: object
Expand Down
2 changes: 1 addition & 1 deletion tools/make/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ go.test.cel: manifests # Run the CEL validation tests
echo "Run CEL Validation on k8s $$ver"; \
go clean -testcache; \
KUBEBUILDER_ASSETS="$$(go tool setup-envtest use $$ver -p path)" \
go test ./test/cel-validation --tags celvalidation -race; \
go test ./test/cel-validation --tags celvalidation -race || exit 1; \
done

.PHONY: go.clean
Expand Down
4 changes: 2 additions & 2 deletions tools/make/kube.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
# To know the available versions check:
# - https://github.com/kubernetes-sigs/controller-tools/blob/main/envtest-releases.yaml
ENVTEST_K8S_VERSION ?= 1.29.4
ENVTEST_K8S_VERSION ?= 1.29.5
# Need run cel validation across multiple versions of k8s
# TODO: zhaohuabing update kubebuilder assets to 1.33.0 when available
ENVTEST_K8S_VERSIONS ?= 1.29.4 1.30.3 1.31.0 1.32.0
ENVTEST_K8S_VERSIONS ?= 1.29.5 1.30.3 1.31.0 1.32.0

# GATEWAY_API_VERSION refers to the version of Gateway API CRDs.
# For more details, see https://gateway-api.sigs.k8s.io/guides/getting-started/#installing-gateway-api
Expand Down