Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate slb/pip/vm/vmss/vmas to track2 sdk #7833

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.36.0
github.com/prometheus/client_golang v1.20.5
github.com/samber/lo v1.47.0
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -124,7 +125,6 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJ
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM=
github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand Down
15 changes: 7 additions & 8 deletions internal/testutil/fixture/azure_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@ limitations under the License.
package fixture

import (
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6"
"k8s.io/utils/ptr"
)

func (f *AzureFixture) LoadBalancer() *AzureLoadBalancerFixture {
return &AzureLoadBalancerFixture{
lb: &network.LoadBalancer{
Name: ptr.To("lb"),
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
lb: &armnetwork.LoadBalancer{
Name: ptr.To("lb"),
Properties: &armnetwork.LoadBalancerPropertiesFormat{
// TODO
},
},
}
}

type AzureLoadBalancerFixture struct {
lb *network.LoadBalancer
lb *armnetwork.LoadBalancer
}

func (f *AzureLoadBalancerFixture) Build() network.LoadBalancer {
return *f.lb
func (f *AzureLoadBalancerFixture) Build() *armnetwork.LoadBalancer {
return f.lb
}

func (f *AzureLoadBalancerFixture) IPv4Addresses() []string {
Expand Down
19 changes: 9 additions & 10 deletions internal/testutil/fixture/azure_publicip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ package fixture
import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6"
"k8s.io/utils/ptr"
)

Expand All @@ -31,20 +30,20 @@ func (f *AzureFixture) PublicIPAddress(name string) *AzurePublicIPAddressFixture
)

return &AzurePublicIPAddressFixture{
pip: &network.PublicIPAddress{
ID: ptr.To(fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", SubscriptionID, ResourceGroup, name)),
Name: ptr.To(name),
Tags: make(map[string]*string),
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{},
pip: &armnetwork.PublicIPAddress{
ID: ptr.To(fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", SubscriptionID, ResourceGroup, name)),
Name: ptr.To(name),
Tags: make(map[string]*string),
Properties: &armnetwork.PublicIPAddressPropertiesFormat{},
},
}
}

type AzurePublicIPAddressFixture struct {
pip *network.PublicIPAddress
pip *armnetwork.PublicIPAddress
}

func (f *AzurePublicIPAddressFixture) Build() network.PublicIPAddress {
func (f *AzurePublicIPAddressFixture) Build() armnetwork.PublicIPAddress {
return *f.pip
}

Expand All @@ -54,6 +53,6 @@ func (f *AzurePublicIPAddressFixture) WithTag(key, value string) *AzurePublicIPA
}

func (f *AzurePublicIPAddressFixture) WithAddress(address string) *AzurePublicIPAddressFixture {
f.pip.PublicIPAddressPropertiesFormat.IPAddress = ptr.To(address)
f.pip.Properties.IPAddress = ptr.To(address)
return f
}
6 changes: 3 additions & 3 deletions kubetest2-aks/deployer/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ func (d *deployer) createAKSWithCustomConfig() error {
return nil
}

// getAKSKubeconfig gets kubeconfig of the AKS cluster and writes it to specific path.
func (d *deployer) getAKSKubeconfig() error {
// getAKSKUbeconfig gets kubeconfig of the AKS cluster and writes it to specific path.
func (d *deployer) getAKSKUbeconfig() error {
klog.Infof("Retrieving AKS cluster's kubeconfig")
client, err := armcontainerservicev2.NewManagedClustersClient(subscriptionID, cred, nil)
if err != nil {
Expand Down Expand Up @@ -397,7 +397,7 @@ func (d *deployer) Up() error {
}

// Get the cluster kubeconfig
if err := d.getAKSKubeconfig(); err != nil {
if err := d.getAKSKUbeconfig(); err != nil {
return fmt.Errorf("failed to get AKS cluster kubeconfig: %v", err)
}
return nil
Expand Down
10 changes: 5 additions & 5 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ const (
// ref: https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#load-balancer.
MaximumLoadBalancerRuleCount = 250

// LoadBalancerSkuBasic is the load balancer basic sku
LoadBalancerSkuBasic = "basic"
// LoadBalancerSkuStandard is the load balancer standard sku
LoadBalancerSkuStandard = "standard"
// LoadBalancerSKUBasic is the load balancer basic SKU
LoadBalancerSKUBasic = "basic"
// LoadBalancerSKUStandard is the load balancer standard SKU
LoadBalancerSKUStandard = "standard"

// ServiceAnnotationLoadBalancerInternal is the annotation used on the service
ServiceAnnotationLoadBalancerInternal = "service.beta.kubernetes.io/azure-load-balancer-internal"
Expand All @@ -246,7 +246,7 @@ const (

// ServiceAnnotationLoadBalancerMode is the annotation used on the service to specify
// which load balancer should be associated with the service. This is valid when using the basic
// sku load balancer, or it would be ignored.
// SKU load balancer, or it would be ignored.
// 1. Default mode - service has no annotation ("service.beta.kubernetes.io/azure-load-balancer-mode")
// In this case the Loadbalancer of the primary VMSS/VMAS is selected.
// 2. "__auto__" mode - service is annotated with __auto__ value, this when loadbalancer from any VMSS/VMAS
Expand Down
22 changes: 11 additions & 11 deletions pkg/nodeipam/ipam/cloud_cidr_allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ import (
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/utils/ptr"

"sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmclient/mockvmclient"
"sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmssclient/mockvmssclient"
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/virtualmachineclient/mock_virtualmachineclient"
"sigs.k8s.io/cloud-provider-azure/pkg/azclient/virtualmachinescalesetclient/mock_virtualmachinescalesetclient"
"sigs.k8s.io/cloud-provider-azure/pkg/consts"
azureprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider"
"sigs.k8s.io/cloud-provider-azure/pkg/util/controller/testutil"
Expand Down Expand Up @@ -208,18 +208,18 @@ func TestUpdateNodeSubnetMaskSizes(t *testing.T) {
ss, err := azureprovider.NewTestScaleSet(ctrl)
assert.NoError(t, err)

expectedVMSS := compute.VirtualMachineScaleSet{
expectedVMSS := &armcompute.VirtualMachineScaleSet{
Name: ptr.To("vmss"),
Tags: tc.tags,
VirtualMachineScaleSetProperties: &compute.VirtualMachineScaleSetProperties{
OrchestrationMode: compute.Uniform,
Properties: &armcompute.VirtualMachineScaleSetProperties{
OrchestrationMode: to.Ptr(armcompute.OrchestrationModeUniform),
},
}
mockVMSSClient := ss.VirtualMachineScaleSetsClient.(*mockvmssclient.MockInterface)
mockVMSSClient.EXPECT().List(gomock.Any(), cloud.ResourceGroup).Return([]compute.VirtualMachineScaleSet{expectedVMSS}, nil).MaxTimes(1)
mockVMSSClient := ss.ComputeClientFactory.GetVirtualMachineScaleSetClient().(*mock_virtualmachinescalesetclient.MockInterface)
mockVMSSClient.EXPECT().List(gomock.Any(), cloud.ResourceGroup).Return([]*armcompute.VirtualMachineScaleSet{expectedVMSS}, nil).MaxTimes(1)
cloud.VMSet = ss
mockVMsClient := ss.VirtualMachinesClient.(*mockvmclient.MockInterface)
mockVMsClient.EXPECT().List(gomock.Any(), gomock.Any()).Return([]compute.VirtualMachine{}, nil).AnyTimes()
mockVMsClient := ss.ComputeClientFactory.GetVirtualMachineClient().(*mock_virtualmachineclient.MockInterface)
mockVMsClient.EXPECT().List(gomock.Any(), gomock.Any()).Return([]*armcompute.VirtualMachine{}, nil).AnyTimes()

clusterCIDRs := func() []*net.IPNet {
_, cidrIPV4, _ := net.ParseCIDR("10.240.0.0/16")
Expand Down
Loading
Loading