Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the endpoint ports to avoid reconciles
Browse files Browse the repository at this point in the history
shraddhabang committed Sep 18, 2024
1 parent 7796c0e commit 886ada2
Showing 4 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions pkg/backend/endpoint_resolver.go
Original file line number Diff line number Diff line change
@@ -284,15 +284,15 @@ func buildEndpointsDataFromEndpointSliceList(epsList *discovery.EndpointSliceLis
func buildPodEndpoint(pod k8s.PodInfo, epAddr string, port int32) PodEndpoint {
return PodEndpoint{
IP: epAddr,
Port: awssdk.Int32(port),
Port: port,
Pod: pod,
}
}

func buildNodePortEndpoint(node *corev1.Node, instanceID string, nodePort int32) NodePortEndpoint {
return NodePortEndpoint{
InstanceID: instanceID,
Port: awssdk.Int32(nodePort),
Port: nodePort,
Node: node,
}
}
46 changes: 23 additions & 23 deletions pkg/backend/endpoint_resolver_test.go
Original file line number Diff line number Diff line change
@@ -768,12 +768,12 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.1",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod1,
},
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -840,12 +840,12 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.1",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod1,
},
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -912,12 +912,12 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.1",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod1,
},
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -974,17 +974,17 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.2",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod2,
},
{
IP: "192.168.1.5",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod5,
},
{
IP: "192.168.1.8",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod8,
},
},
@@ -1102,12 +1102,12 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.1",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod1,
},
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -1169,12 +1169,12 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.1",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod1,
},
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -1236,7 +1236,7 @@ func Test_defaultEndpointResolver_ResolvePodEndpoints(t *testing.T) {
want: []PodEndpoint{
{
IP: "192.168.1.4",
Port: awssdk.Int32(8080),
Port: 8080,
Pod: pod4,
},
},
@@ -1539,12 +1539,12 @@ func Test_defaultEndpointResolver_ResolveNodePortEndpoints(t *testing.T) {
want: []NodePortEndpoint{
{
InstanceID: "i-abcdefg1",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node1,
},
{
InstanceID: "i-abcdefg2",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node2,
},
},
@@ -1566,12 +1566,12 @@ func Test_defaultEndpointResolver_ResolveNodePortEndpoints(t *testing.T) {
want: []NodePortEndpoint{
{
InstanceID: "i-abcdefg1",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node1,
},
{
InstanceID: "i-abcdefg2",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node2,
},
},
@@ -1593,12 +1593,12 @@ func Test_defaultEndpointResolver_ResolveNodePortEndpoints(t *testing.T) {
want: []NodePortEndpoint{
{
InstanceID: "i-abcdefg3",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node3,
},
{
InstanceID: "i-abcdefg4",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node4,
},
},
@@ -1633,7 +1633,7 @@ func Test_defaultEndpointResolver_ResolveNodePortEndpoints(t *testing.T) {
want: []NodePortEndpoint{
{
InstanceID: "i-abcdefg1",
Port: awssdk.Int32(18080),
Port: 18080,
Node: node1,
},
},
@@ -2609,7 +2609,7 @@ func Test_buildPodEndpoint(t *testing.T) {
},
want: PodEndpoint{
IP: "192.168.1.1",
Port: awssdk.Int32(80),
Port: 80,
Pod: k8s.PodInfo{
Key: types.NamespacedName{Name: "sample-node"},
},
@@ -2653,7 +2653,7 @@ func Test_buildNodePortEndpoint(t *testing.T) {
},
},
InstanceID: "i-xxxxx",
Port: awssdk.Int32(33382),
Port: 33382,
},
},
}
4 changes: 2 additions & 2 deletions pkg/backend/endpoint_types.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ type PodEndpoint struct {
// Pod's IP.
IP string
// Pod's container port.
Port *int32
Port int32
// Pod that provides this endpoint.
Pod k8s.PodInfo
}
@@ -22,7 +22,7 @@ type NodePortEndpoint struct {
// Node's instanceID.
InstanceID string
// Node's NodePort.
Port *int32
Port int32
// Node that provides this endpoint.
Node *corev1.Node
}
4 changes: 2 additions & 2 deletions pkg/targetgroupbinding/resource_manager.go
Original file line number Diff line number Diff line change
@@ -407,7 +407,7 @@ func (m *defaultResourceManager) registerPodEndpoints(ctx context.Context, tgARN
for _, endpoint := range endpoints {
target := elbv2types.TargetDescription{
Id: awssdk.String(endpoint.IP),
Port: endpoint.Port,
Port: awssdk.Int32(endpoint.Port),
}
podIP, err := netip.ParseAddr(endpoint.IP)
if err != nil {
@@ -426,7 +426,7 @@ func (m *defaultResourceManager) registerNodePortEndpoints(ctx context.Context,
for _, endpoint := range endpoints {
sdkTargets = append(sdkTargets, elbv2types.TargetDescription{
Id: awssdk.String(endpoint.InstanceID),
Port: endpoint.Port,
Port: awssdk.Int32(endpoint.Port),
})
}
return m.targetsManager.RegisterTargets(ctx, tgARN, sdkTargets)

0 comments on commit 886ada2

Please sign in to comment.