Skip to content

Commit

Permalink
enhance: avoid misjudgement on DualStack ip family when parsing netwo…
Browse files Browse the repository at this point in the history
…rk config from existing IPInstances
  • Loading branch information
sjtufl committed May 28, 2024
1 parent e825742 commit 7b515cf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/webhook/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,22 @@ func parseNetworkConfigByExistIPInstances(ctx context.Context, c client.Reader,
ipFamily = ipamtypes.IPv4
}
case 2:
ipFamily = ipamtypes.DualStack
var (
v4Count = 0
v6Count = 0
)
for i := range validIPList {
if networkingv1.IsIPv6IPInstance(&validIPList[i]) {
v6Count++
} else {
v4Count++
}
}
if v4Count == 1 && v6Count == 1 {
ipFamily = ipamtypes.DualStack
} else {
err = fmt.Errorf("more than two ip instances are of the same family type, ipv4 count %d, ipv6 count %d", v4Count, v6Count)
}
default:
err = fmt.Errorf("more than two reserve ip exist for list options %v", opts)
return
Expand Down

0 comments on commit 7b515cf

Please sign in to comment.