Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(meshexternalservice): remove unix support #11350

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1901,9 +1901,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
5 changes: 2 additions & 3 deletions docs/generated/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11171,9 +11171,8 @@ components:
address:
description: >-
Address defines an address to which a user want to send a
request. Is possible to provide `domain`, `ip` and `unix`
sockets.
example: unix:///tmp/example.sock
request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
5 changes: 2 additions & 3 deletions docs/generated/raw/crds/kuma.io_meshexternalservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ type Extension struct {
type Port int

type Endpoint struct {
// Address defines an address to which a user want to send a request. Is possible to provide `domain`, `ip` and `unix` sockets.
// Address defines an address to which a user want to send a request. Is possible to provide `domain`, `ip`.
// +kubebuilder:example="127.0.0.1"
// +kubebuilder:example="example.com"
// +kubebuilder:example="unix:///tmp/example.sock"
// +kubebuilder:validation:MinLength=1
Address string `json:"address"`
// Port of the endpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ properties:
items:
properties:
address:
description: Address defines an address to which a user want to send a request. Is possible to provide `domain`, `ip` and `unix` sockets.
example: unix:///tmp/example.sock
description: Address defines an address to which a user want to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ endpoints:
- address: 1.1.1.2
port: 999999
- address: example.com
- address: unix:///tmp/example.sock
port: 80
- port: 90
tls:
version:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ violations:
message: port must be a valid (1-65535)
- field: spec.endpoints[2].port
message: must be defined when endpoint is a hostname
- field: spec.endpoints[3].port
message: must not be defined when endpoint is a unix path
- field: spec.endpoints[4].address
message: address has to be a valid IP or hostname or a unix path
- field: spec.endpoints[3].address
message: address has to be a valid IP or hostname
- field: spec.tls.version.min
message: '"min" must be one of ["TLSAuto", "TLS10", "TLS11", "TLS12", "TLS13"]'
- field: spec.tls.version.max
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ endpoints:
port: 12345
- address: example.com
port: 80
- address: unix:///tmp/example.sock
tls:
version:
min: TLS12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"math"
"slices"
"strings"

"github.com/asaskevich/govalidator"

Expand Down Expand Up @@ -106,32 +105,16 @@ func validateEndpoints(endpoints []Endpoint) validators.ValidationError {
}
}

if isValidUnixPath(endpoint.Address) {
if endpoint.Port != nil {
verr.AddViolationAt(validators.Root().Index(i).Field("port"), validators.MustNotBeDefined+" when endpoint is a unix path")
}
}

if govalidator.IsDNSName(endpoint.Address) {
if endpoint.Port == nil {
verr.AddViolationAt(validators.Root().Index(i).Field("port"), validators.MustBeDefined+" when endpoint is a hostname")
}
}

if !(govalidator.IsIP(endpoint.Address) || govalidator.IsDNSName(endpoint.Address) || isValidUnixPath(endpoint.Address)) {
verr.AddViolationAt(validators.Root().Index(i).Field("address"), "address has to be a valid IP or hostname or a unix path")
if !(govalidator.IsIP(endpoint.Address) || govalidator.IsDNSName(endpoint.Address)) {
verr.AddViolationAt(validators.Root().Index(i).Field("address"), "address has to be a valid IP or hostname")
}
}

return verr
}

func isValidUnixPath(path string) bool {
if strings.HasPrefix(path, "unix://") {
parts := strings.Split(path, "unix://")
filePath := parts[1]
return govalidator.IsUnixFilePath(filePath)
} else {
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ spec:
properties:
address:
description: Address defines an address to which a user want
to send a request. Is possible to provide `domain`, `ip` and
`unix` sockets.
example: unix:///tmp/example.sock
to send a request. Is possible to provide `domain`, `ip`.
example: example.com
minLength: 1
type: string
port:
Expand Down
26 changes: 7 additions & 19 deletions pkg/xds/topology/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"maps"
"net"
"strconv"
"strings"

"github.com/asaskevich/govalidator"
"github.com/pkg/errors"
Expand Down Expand Up @@ -734,24 +733,13 @@ func createMeshExternalServiceEndpoint(
if i == 0 && es.ServerName == "" && govalidator.IsDNSName(endpoint.Address) && tls != nil && tls.Enabled {
es.ServerName = endpoint.Address
}
var outboundEndpoint *core_xds.Endpoint
if strings.HasPrefix(endpoint.Address, "unix://") {
outboundEndpoint = &core_xds.Endpoint{
UnixDomainPath: endpoint.Address,
Weight: 1,
ExternalService: es,
Tags: tags,
Locality: GetLocality(zone, getZone(tags), mesh.LocalityAwareLbEnabled()),
}
} else {
outboundEndpoint = &core_xds.Endpoint{
Target: endpoint.Address,
Port: uint32(*endpoint.Port),
Weight: 1,
ExternalService: es,
Tags: tags,
Locality: GetLocality(zone, getZone(tags), mesh.LocalityAwareLbEnabled()),
}
outboundEndpoint := &core_xds.Endpoint{
Target: endpoint.Address,
Port: uint32(*endpoint.Port),
Weight: 1,
ExternalService: es,
Tags: tags,
Locality: GetLocality(zone, getZone(tags), mesh.LocalityAwareLbEnabled()),
}
outbounds[name] = append(outbounds[name], *outboundEndpoint)
}
Expand Down
30 changes: 0 additions & 30 deletions pkg/xds/topology/outbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,24 +1406,6 @@ var _ = Describe("TrafficRoute", func() {
},
},
},
{
Meta: &test_model.ResourceMeta{
Mesh: "default",
Name: "no-tls-mes",
},
Spec: &meshexternalservice_api.MeshExternalService{
Match: meshexternalservice_api.Match{
Type: pointer.To(meshexternalservice_api.HostnameGeneratorType),
Port: 10000,
Protocol: meshexternalservice_api.GrpcProtocol,
},
Endpoints: []meshexternalservice_api.Endpoint{
{
Address: "unix://no-tls-mes",
},
},
},
},
},
zoneEgresses: []*core_mesh.ZoneEgressResource{
{
Expand Down Expand Up @@ -1456,18 +1438,6 @@ var _ = Describe("TrafficRoute", func() {
},
},
},
"no-tls-mes": []core_xds.Endpoint{
{
Target: "1.1.1.1",
Port: 10002,
Locality: nil,
Weight: 1,
ExternalService: &core_xds.ExternalService{
Protocol: core_mesh.ProtocolGRPC,
TLSEnabled: false,
},
},
},
"example-mes": []core_xds.Endpoint{
{
Target: "1.1.1.1",
Expand Down
Loading