Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/cloudprovider/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
utilnet "k8s.io/utils/net"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -218,8 +219,9 @@ func (a *AWS) GetNodeEgressIPConfiguration(node *corev1.Node, cloudPrivateIPConf
return nil, err
}
config.Capacity = capacity{
IPv4: capV4,
IPv6: capV6,
IPv4: ptr.To(capV4),
IPv6: ptr.To(capV6),
// IP field not used by AWS (uses per-IP-family capacity)
}
return []*NodeEgressIPConfiguration{config}, nil
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/cloudprovider/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package cloudprovider
import (
"context"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"k8s.io/utils/ptr"
"net"
"os"
"strings"
"sync"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"k8s.io/utils/ptr"

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
Expand Down Expand Up @@ -351,7 +352,8 @@ func (a *Azure) GetNodeEgressIPConfiguration(node *corev1.Node, cloudPrivateIPCo
config.IFAddr.IPv6 = v6Subnet.String()
}
config.Capacity = capacity{
IP: a.getCapacity(networkInterface, len(cloudPrivateIPConfigs)),
// IPv4 and IPv6 fields not used by Azure (uses IP-family-agnostic capacity)
IP: ptr.To(a.getCapacity(networkInterface, len(cloudPrivateIPConfigs))),
}
return []*NodeEgressIPConfiguration{config}, nil
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/cloudprovider/cloudprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"
"errors"
"fmt"
apifeatures "github.com/openshift/api/features"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"net"
"os"
"path/filepath"
"sync"

configv1 "github.com/openshift/api/config/v1"
apifeatures "github.com/openshift/api/features"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"

v1 "github.com/openshift/api/cloudnetwork/v1"
corev1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -102,9 +103,9 @@ type ifAddr struct {
}

type capacity struct {
IPv4 int `json:"ipv4,omitempty"`
IPv6 int `json:"ipv6,omitempty"`
IP int `json:"ip,omitempty"`
IPv4 *int `json:"ipv4,omitempty"`
IPv6 *int `json:"ipv6,omitempty"`
IP *int `json:"ip,omitempty"`
}

// NodeEgressIPConfiguration stores details - specific to each cloud - which are
Expand Down
4 changes: 3 additions & 1 deletion pkg/cloudprovider/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"google.golang.org/api/option"
corev1 "k8s.io/api/core/v1"
utilnet "k8s.io/utils/net"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -182,7 +183,8 @@ func (g *GCP) GetNodeEgressIPConfiguration(node *corev1.Node, cloudPrivateIPConf
config.IFAddr.IPv6 = v6Subnet.String()
}
config.Capacity = capacity{
IP: g.getCapacity(networkInterface, len(cloudPrivateIPConfigs)),
// IPv4 and IPv6 fields not used by GCP (uses IP-family-agnostic capacity)
IP: ptr.To(g.getCapacity(networkInterface, len(cloudPrivateIPConfigs))),
}
return []*NodeEgressIPConfiguration{config}, nil //nolint:staticcheck
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/cloudprovider/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"k8s.io/client-go/util/retry"
"k8s.io/klog/v2"
utilnet "k8s.io/utils/net"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -608,7 +609,8 @@ func (o *OpenStack) getNeutronPortNodeEgressIPConfiguration(p neutronports.Port,
IPv6: ipv6,
},
Capacity: capacity{
IP: c,
// IPv4 and IPv6 fields not used by OpenStack (uses IP-family-agnostic capacity)
IP: ptr.To(c),
},
}, nil
}
Expand Down
17 changes: 9 additions & 8 deletions pkg/cloudprovider/openstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -677,7 +678,7 @@ func TestOpenStackPlugin(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
}
Expand Down Expand Up @@ -804,7 +805,7 @@ func TestGetNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
},
Expand Down Expand Up @@ -840,7 +841,7 @@ func TestGetNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2001::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
},
Expand Down Expand Up @@ -884,7 +885,7 @@ func TestGetNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
},
Expand Down Expand Up @@ -931,7 +932,7 @@ func TestGetNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
},
Expand All @@ -943,7 +944,7 @@ func TestGetNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2001::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity,
IP: ptr.To(openstackMaxCapacity),
},
},
},
Expand Down Expand Up @@ -1028,7 +1029,7 @@ func TestGetNeutronPortNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity - 2, // 2 allowed_address_pairs configured on the port.
IP: ptr.To(openstackMaxCapacity - 2), // 2 allowed_address_pairs configured on the port.
},
},
},
Expand All @@ -1041,7 +1042,7 @@ func TestGetNeutronPortNodeEgressIPConfiguration(t *testing.T) {
IPv6: "2000::/64",
},
Capacity: capacity{
IP: openstackMaxCapacity + 3 - 2, // excluding 2 allowed_address_pairs configured on the port.
IP: ptr.To(openstackMaxCapacity + 3 - 2), // excluding 2 allowed_address_pairs configured on the port.
},
},
// Configure cloudPrivateIPConfigs with 3 ips are within neutron subnet, 1 ip outside neutron subnet.
Expand Down