Skip to content

Commit

Permalink
Creating Ingress IP loadbalancer alone when all the endpoints are ter…
Browse files Browse the repository at this point in the history
…minating. KEP1669
  • Loading branch information
princepereira committed Dec 13, 2022
1 parent dd0b0c0 commit e553967
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 41 deletions.
16 changes: 15 additions & 1 deletion pkg/proxy/winkernel/hns.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ func (hns hns) deleteEndpoint(hnsID string) error {
return err
}

// findLoadBalancerID will construct a id from the provided loadbalancer fields
func findLoadBalancerID(endpoints []endpointsInfo, vip string, protocol, internalPort, externalPort uint16) (loadBalancerIdentifier, error) {
// Compute hash from backends (endpoint IDs)
hash, err := hashEndpoints(endpoints)
if err != nil {
klog.V(2).ErrorS(err, "Error hashing endpoints", "endpoints", endpoints)
return loadBalancerIdentifier{}, err
}
if len(vip) > 0 {
return loadBalancerIdentifier{protocol: protocol, internalPort: internalPort, externalPort: externalPort, vip: vip, endpointsHash: hash}, nil
}
return loadBalancerIdentifier{protocol: protocol, internalPort: internalPort, externalPort: externalPort, endpointsHash: hash}, nil
}

func (hns hns) getAllLoadBalancers() (map[loadBalancerIdentifier]*loadBalancerInfo, error) {
lbs, err := hcn.ListLoadBalancers()
var id loadBalancerIdentifier
Expand Down Expand Up @@ -391,7 +405,7 @@ func hashEndpoints[T string | endpointsInfo](endpoints []T) (hash [20]byte, err
for _, ep := range endpoints {
switch x := any(ep).(type) {
case endpointsInfo:
id = x.hnsID
id = strings.ToUpper(x.hnsID)
case string:
id = x
}
Expand Down
Loading

0 comments on commit e553967

Please sign in to comment.