Skip to content

Commit

Permalink
Merge pull request #1157 from spidernet-io/fix/update-egw
Browse files Browse the repository at this point in the history
Fix: failed to update IP address of egw
  • Loading branch information
weizhoublue authored Jan 26, 2024
2 parents 9030091 + 8811187 commit 320f425
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/egressgateway/egress_gateway_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (egw *EgressGatewayWebhook) EgressGatewayValidate(ctx context.Context, req
if err != nil {
return webhook.Denied(fmt.Sprintf("Failed to get EgressGatewayList: %v", err))
}
clusterMap, err := buildClusterIPMap(egwList)
clusterMap, err := buildClusterIPMap(egwList, newEg.Name)
if err != nil {
return webhook.Denied(fmt.Sprintf("Failed to build cluster EgressGateway IP map: %v", err))
}
Expand Down Expand Up @@ -197,9 +197,13 @@ func (egw *EgressGatewayWebhook) EgressGatewayValidate(ctx context.Context, req
return webhook.Allowed("checked")
}

func buildClusterIPMap(egwList *egress.EgressGatewayList) (map[string]map[string]struct{}, error) {
func buildClusterIPMap(egwList *egress.EgressGatewayList, skipName string) (map[string]map[string]struct{}, error) {
res := make(map[string]map[string]struct{})
for _, item := range egwList.Items {
if item.Name == skipName {
continue
}

var ipv4s, ipv6s []net.IP
ipv4Ranges, err := ip.MergeIPRanges(constant.IPv4, item.Spec.Ippools.IPv4)
if err != nil {
Expand Down

0 comments on commit 320f425

Please sign in to comment.