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
8 changes: 5 additions & 3 deletions pkg/utils/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"net"

"github.com/api7/gopkg/pkg/log"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -72,9 +74,7 @@ func ConvertEndpointsToEndpointSlice(ep *corev1.Endpoints) []discoveryv1.Endpoin
epPort := discoveryv1.EndpointPort{
Port: &p.Port,
Protocol: &p.Protocol,
}
if p.Name != "" {
epPort.Name = &p.Name
Name: &p.Name,
}
ports = append(ports, epPort)
}
Expand Down Expand Up @@ -140,6 +140,8 @@ func ConvertEndpointsToEndpointSlice(ep *corev1.Endpoints) []discoveryv1.Endpoin
}
}

log.Debugw("Converted Endpoints to EndpointSlices", zap.Any("endpointSlices", endpointSlices))

return endpointSlices
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func TestConvertEndpointsToEndpointSlice(t *testing.T) {
},
want: []discoveryv1.EndpointSlice{
createTestEndpointSlice("test-service-0-v4", discoveryv1.AddressTypeIPv4,
[]discoveryv1.EndpointPort{createPlainPort(80)},
[]discoveryv1.EndpointPort{createPlainPortWithEmptyName(80)},
[]discoveryv1.Endpoint{createEndpointWithHostname("192.168.1.1", "pod-1")}),
},
},
Expand Down Expand Up @@ -462,8 +462,9 @@ func createHTTPSPort(port int32) discoveryv1.EndpointPort {
}
}

func createPlainPort(port int32) discoveryv1.EndpointPort {
func createPlainPortWithEmptyName(port int32) discoveryv1.EndpointPort {
return discoveryv1.EndpointPort{
Name: ptr.To(""),
Port: ptr.To(port),
Protocol: ptr.To(corev1.ProtocolTCP),
}
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/scaffold/httpbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ spec:
selector:
app: httpbin-deployment-e2e-test
ports:
- name: http
port: 80
- port: 80
protocol: TCP
targetPort: 80
type: ClusterIP
Expand Down
Loading