Skip to content

Commit

Permalink
refactor: Remove custom code used by old Azure SDK - part 2 (#423)
Browse files Browse the repository at this point in the history
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
  • Loading branch information
helayoty authored Jan 24, 2023
1 parent a628b01 commit 80d7d19
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 284 deletions.
143 changes: 0 additions & 143 deletions pkg/client/client.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/client/client_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

type AzClientsInterface interface {
ContainerGroupGetter
CreateContainerGroup(ctx context.Context, resourceGroup, podNS, podName string, cg *ContainerGroupWrapper) error
CreateContainerGroup(ctx context.Context, resourceGroup, podNS, podName string, cg *azaciv2.ContainerGroup) error
GetContainerGroupInfo(ctx context.Context, resourceGroup, namespace, name, nodeName string) (*azaciv2.ContainerGroup, error)
GetContainerGroupListResult(ctx context.Context, resourceGroup string) ([]*azaciv2.ContainerGroup, error)
ListCapabilities(ctx context.Context, region string) ([]*azaciv2.Capabilities, error)
Expand Down Expand Up @@ -113,14 +113,14 @@ func (a *AzClientsAPIs) GetContainerGroup(ctx context.Context, resourceGroup, co
return &result.ContainerGroup, nil
}

func (a *AzClientsAPIs) CreateContainerGroup(ctx context.Context, resourceGroup, podNS, podName string, cg *ContainerGroupWrapper) error {
func (a *AzClientsAPIs) CreateContainerGroup(ctx context.Context, resourceGroup, podNS, podName string, cg *azaciv2.ContainerGroup) error {
logger := log.G(ctx).WithField("method", "CreateContainerGroup")
ctx, span := trace.StartSpan(ctx, "client.CreateContainerGroup")
defer span.End()
cgName := containerGroupName(podNS, podName)

containerGroup := azaciv2.ContainerGroup{
Properties: cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Properties,
Properties: cg.Properties,
Name: &cgName,
Type: cg.Type,
Identity: cg.Identity,
Expand Down
60 changes: 0 additions & 60 deletions pkg/client/retry.go

This file was deleted.

5 changes: 2 additions & 3 deletions pkg/metrics/mock_metrics_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions pkg/network/aci_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
azaciv2 "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2"
aznetwork "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-05-01/network"
"github.com/virtual-kubelet/azure-aci/pkg/auth"
client2 "github.com/virtual-kubelet/azure-aci/pkg/client"
"github.com/virtual-kubelet/virtual-kubelet/log"
v1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -177,18 +176,18 @@ func (pn *ProviderNetwork) setupNetwork(ctx context.Context, azConfig *auth.Conf
return nil
}

func (pn *ProviderNetwork) AmendVnetResources(ctx context.Context, cg client2.ContainerGroupWrapper, pod *v1.Pod, clusterDomain string) {
func (pn *ProviderNetwork) AmendVnetResources(ctx context.Context, cg azaciv2.ContainerGroup, pod *v1.Pod, clusterDomain string) {
if pn.SubnetName == "" {
return
}

subnetID := "/subscriptions/" + pn.VnetSubscriptionID + "/resourceGroups/" + pn.VnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + pn.VnetName + "/subnets/" + pn.SubnetName
cgIDList := []*azaciv2.ContainerGroupSubnetID{{ID: &subnetID}}
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Properties.SubnetIDs = cgIDList
cg.Properties.SubnetIDs = cgIDList
// windows containers don't support DNS config
if cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Properties.OSType != nil &&
*cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Properties.OSType != azaciv2.OperatingSystemTypesWindows {
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Properties.DNSConfig = getDNSConfig(ctx, pod, pn.KubeDNSIP, clusterDomain)
if cg.Properties.OSType != nil &&
*cg.Properties.OSType != azaciv2.OperatingSystemTypesWindows {
cg.Properties.DNSConfig = getDNSConfig(ctx, pod, pn.KubeDNSIP, clusterDomain)
}
}

Expand Down
Loading

0 comments on commit 80d7d19

Please sign in to comment.