Skip to content

Commit b71c9a0

Browse files
committed
wip
Signed-off-by: Patryk Diak <[email protected]>
1 parent 36d6842 commit b71c9a0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

pkg/cloudprovider/gcp.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
corev1 "k8s.io/api/core/v1"
1414
"k8s.io/apimachinery/pkg/util/sets"
1515
"k8s.io/utils/ptr"
16+
"k8s.io/klog/v2"
1617
)
1718

1819
const (
@@ -246,6 +247,7 @@ func (g *GCP) getSubnet(networkInterface *google.NetworkInterface) (*net.IPNet,
246247
// Note: there is also a global "alias IP per VPC quota", but OpenShift clusters on
247248
// GCP seem to have that value defined to 15,000. So we can skip that.
248249
func (g *GCP) getCapacity(networkInterface *google.NetworkInterface, cpicIPs sets.Set[string]) int {
250+
klog.Infof("getCapacity, existing cpicIPs: %+v", cpicIPs)
249251
currentIPUsage := 0
250252
for _, aliasIPRange := range networkInterface.AliasIpRanges {
251253
var aliasIP net.IP
@@ -256,6 +258,7 @@ func (g *GCP) getCapacity(networkInterface *google.NetworkInterface, cpicIPs set
256258
}
257259

258260
if aliasIP != nil && !cpicIPs.Has(aliasIP.String()) {
261+
klog.Infof("getCapacity, assigned IP address %s", aliasIP.String())
259262
currentIPUsage++
260263
}
261264
}

pkg/cloudprovider/openstack.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ func (o *OpenStack) getNeutronPortNodeEgressIPConfiguration(p neutronports.Port,
567567
// Loop over all subnets. OpenStack potentially has several IPv4 or IPv6 subnets per port, but the
568568
// CloudPrivateIPConfig expects only a single subnet of each address family per port. Throw an error
569569
// in such a case.
570-
var cloudPrivateIPsCount int
571570
for _, s := range subnets {
572571
// Parse CIDR information into ip and ipnet.
573572
ip, ipnet, err = net.ParseCIDR(s.CIDR)
@@ -587,13 +586,14 @@ func (o *OpenStack) getNeutronPortNodeEgressIPConfiguration(p neutronports.Port,
587586
}
588587
ipv6 = ipnet.String()
589588
}
590-
// Loop over all cloudPrivateIPConfigs and check if they are part of this ipnet.
591-
// If the IP is contained in the ipnet, increase cloudPrivateIPsCount.
592-
for ipStr := range cpicIPs {
593-
cip := net.ParseIP(ipStr)
594-
if cip != nil && ipnet.Contains(cip) {
595-
cloudPrivateIPsCount++
596-
}
589+
}
590+
591+
// Loop over all cloudPrivateIPConfigs and check if they are part of this port.
592+
// If the IP is contained in the port, increase cloudPrivateIPsCount.
593+
cloudPrivateIPsCount := 0
594+
for _, portIP := range p.AllowedAddressPairs {
595+
if cpicIPs.Has(portIP.IPAddress) {
596+
cloudPrivateIPsCount++
597597
}
598598
}
599599

0 commit comments

Comments
 (0)