Skip to content

Hardcoded virtualnetworklink suffix causes issues if virtualnetworklink already exists with different name #6520

Open
@frank-m

Description

@frank-m

What happened:

vNetLinkName := vnetName + "-vnetlink"
if _, err := clientFactory.GetVirtualNetworkLinkClient().Get(ctx, vnetResourceGroup, privateDNSZoneName, vNetLinkName); err != nil {
if strings.Contains(err.Error(), consts.ResourceNotFoundMessageCode) {
if err := az.createVNetLink(ctx, vNetLinkName, vnetResourceGroup, vnetName, privateDNSZoneName); err != nil {
return "", "", fmt.Errorf("create virtual link for vnet(%s) and DNS Zone(%s) in resourceGroup(%s): %w", vnetName, privateDNSZoneName, vnetResourceGroup, err)
}
} else {
return "", "", fmt.Errorf("get virtual link for vnet(%s) and DNS Zone(%s) in resourceGroup(%s) returned with %w", vnetName, privateDNSZoneName, vnetResourceGroup, err)
}
}
}

This piece of code assumes that all virtual networks have a name with the '-vnetlink' suffix.

If this is not the case it will try to create the vnetlink, but if a different link already exists for the same vnet. It will fail.

What you expected to happen:

The code should get all virtualnetworklinks and check if one already exists for that vnet (preferably with the Resource ID of the vNet). If it exists, it should not try to create a new virtualnetworklink as only one can exist per vnet.

How to reproduce it (as minimally and precisely as possible):

We hit this issue while upgrading from AKS 1.27 --> 1.28. This also upgrades the CSI drivers, which use this provider. Initially you notice no issues, but when you try to do any actions on your PVC it will report in the logs with errors about not being able to create the virtualnetworklink.

Anything else we need to know?:

The workaround is to manually delete the vnetlink and recreate it with the '-vnetlink' suffix, however that causes a temporary failure in name resolution (depending on TTL of records)

Environment:

  • Kubernetes version (use kubectl version): happened after upgrading from AKS 1.27 --> 1.28.9
  • Cloud provider or hardware configuration: Azure AKS
  • OS (e.g: cat /etc/os-release): Ubuntu
  • Kernel (e.g. uname -a): -
  • Install tools: -
  • Network plugin and version (if this is a network-related bug):-
  • Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions