Skip to content

Commit

Permalink
Roll back unrelated changes
Browse files Browse the repository at this point in the history
Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
  • Loading branch information
helayoty committed Jan 19, 2023
1 parent 45aa516 commit 037875a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 8 additions & 0 deletions cmd/init-container/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ func main() {
return true
}, func() error {
var providerNetwork network.ProviderNetwork
if azConfig.AKSCredential != nil {
providerNetwork.VnetName = azConfig.AKSCredential.VNetName
if azConfig.AKSCredential.VNetResourceGroup != "" {
providerNetwork.VnetResourceGroup = azConfig.AKSCredential.VNetResourceGroup
} else {
providerNetwork.VnetResourceGroup = azConfig.AKSCredential.ResourceGroup
}
}
// Check or set up a network for VK
log.G(ctx).Debug("setting up the network configuration")
err = providerNetwork.SetVNETConfig(ctx, &azConfig)
Expand Down
4 changes: 0 additions & 4 deletions pkg/network/aci_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (pn *ProviderNetwork) SetVNETConfig(ctx context.Context, azConfig *auth.Con
ctx, span := trace.StartSpan(ctx, "network.SetVNETConfig")
defer span.End()

if azConfig.AKSCredential != nil {
pn.VnetName = azConfig.AKSCredential.VNetName
pn.VnetResourceGroup = azConfig.AKSCredential.VNetResourceGroup
}
// the VNET subscription ID by default is authentication subscription ID.
// We need to override when using cross subscription virtual network resource
pn.VnetSubscriptionID = azConfig.AuthConfig.SubscriptionID
Expand Down
17 changes: 9 additions & 8 deletions pkg/provider/aci.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type ACIProvider struct {
resourceManager *manager.ResourceManager
containerGroupExtensions []*client2.Extension
enabledFeatures *featureflag.FlagIdentifier
ProviderNetwork network.ProviderNetwork
providernetwork network.ProviderNetwork

resourceGroup string
region string
Expand Down Expand Up @@ -193,11 +193,12 @@ func NewACIProvider(ctx context.Context, config string, azConfig auth.Config, az
if azConfig.AKSCredential != nil {
p.resourceGroup = azConfig.AKSCredential.ResourceGroup
p.region = azConfig.AKSCredential.Region

p.providernetwork.VnetName = azConfig.AKSCredential.VNetName
p.providernetwork.VnetResourceGroup = azConfig.AKSCredential.VNetResourceGroup
}

if p.ProviderNetwork.VnetResourceGroup == "" {
p.ProviderNetwork.VnetResourceGroup = p.resourceGroup
if p.providernetwork.VnetResourceGroup == "" {
p.providernetwork.VnetResourceGroup = p.resourceGroup
}
// If the log analytics file has been specified, load workspace credentials from the file
if logAnalyticsAuthFile := os.Getenv("LOG_ANALYTICS_AUTH_LOCATION"); logAnalyticsAuthFile != "" {
Expand Down Expand Up @@ -250,11 +251,11 @@ func NewACIProvider(ctx context.Context, config string, azConfig auth.Config, az
return nil, err
}

if err := p.ProviderNetwork.SetVNETConfig(ctx, &azConfig); err != nil {
if err := p.providernetwork.SetVNETConfig(ctx, &azConfig); err != nil {
return nil, err
}

if p.ProviderNetwork.SubnetName != "" {
if p.providernetwork.SubnetName != "" {
// windows containers don't support kube-proxy nor realtime metrics
if p.operatingSystem != string(azaci.OperatingSystemTypesWindows) {
err = p.setACIExtensions(ctx)
Expand Down Expand Up @@ -342,7 +343,7 @@ func (p *ACIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error {
})
}
}
if len(ports) > 0 && p.ProviderNetwork.SubnetName == "" {
if len(ports) > 0 && p.providernetwork.SubnetName == "" {
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.IPAddress = &azaci.IPAddress{
Ports: &ports,
Type: azaci.ContainerGroupIPAddressTypePublic,
Expand All @@ -364,7 +365,7 @@ func (p *ACIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error {
"CreationTimestamp": &podCreationTimestamp,
}

p.ProviderNetwork.AmendVnetResources(ctx, *cg, pod, p.clusterDomain)
p.providernetwork.AmendVnetResources(ctx, *cg, pod, p.clusterDomain)

// windows containers don't support kube-proxy nor realtime metrics
if cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.OsType != azaci.OperatingSystemTypesWindows {
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *ACIProvider) loadConfig(r io.Reader) error {

// default subnet name
if config.SubnetName != "" {
p.ProviderNetwork.SubnetName = config.SubnetName
p.providernetwork.SubnetName = config.SubnetName
}
if config.SubnetCIDR != "" {
if config.SubnetName == "" {
Expand Down

0 comments on commit 037875a

Please sign in to comment.