Skip to content
New issue

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

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

Already on GitHub? # to your account

Virtual Network module fails when deploying to a network that has existing workloads in it #1111

Closed
ahmadabdalla opened this issue Mar 9, 2022 · 3 comments · Fixed by #1112
Labels
bug Something isn't working

Comments

@ahmadabdalla
Copy link
Contributor

ahmadabdalla commented Mar 9, 2022

If the virtual network already contains workloads in it, attempting to redeploy the vnet results in failure.

Description

The reason is that we are defining the subnet resources outside of the virtual network resource, and that tries to delete all the subnets in the virtual network, which fails. Although we are defining the subnets as a child resource. This doesn't work with this type of resource as all the subnets need to be in the VNET resource.

This was discovered when running the dependency pipeline (in a fork) and had the following error:

     | 3:53:28 PM - The deployment 'virtualNetworks-20220309T1503008054Z' failed with error(s). Showing 1 out of 1 error(s).
Status Message: Subnet crawl-az-subnet-x-001 is in use by /subscriptions/20d6fbfe-b049-471c-95af-1369d14d0d45/resourceGroups/validation-rg/providers/Microsoft.Network/networkInterfaces/adp-crawl-vm-01-nic-01/ipConfigurations/ipconfig01 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet. (Code: InUseSubnetCannotBeDeleted)
CorrelationId: b833c292-0cba-4699-91b1-3213358bbb78

Additional references.

Looking up this issue, I can see it already raised here Azure/bicep-types-az#1687 with the recommendation to have it in the single vnet resource Azure/bicep-types-az#1687 and this is also still an open item here Azure/azure-quickstart-templates#2786

Steps to reproduce

  1. Create a VNET using the module
  2. Create a workload in that VNET
  3. Redeploy the VNET module

Screenshots

During a deployment, this is what happens inside the VNET (when it doesn't have resources)
image

However, this does solve it (AS A WORKAROUND) and a roll back to the PR #1081
image

We need to discuss on:

@ahmadabdalla ahmadabdalla added the bug Something isn't working label Mar 9, 2022
@ahmadabdalla ahmadabdalla added this to the v 0.5 milestone Mar 9, 2022
@AlexanderSehr
Copy link
Contributor

Hey @ahmadabdalla, we should definitely not roll back 1:1 as I removed it one purpose due to an issue that was caused by keeping it (most notably e.g. that the original implementation would clash with ALZ policies). I'd suggest we either find a way to reference 'existing' subnets and pass them in (e.g. with an existing reference if that doesn't throw an exception if empty), or we must duplicate the child resource's property (which would be the worst case scenario).

@ahmadabdalla
Copy link
Contributor Author

@MrMCake what is the clash you're referring to? The subnet being embedded in the vnet resource?

@AlexanderSehr
Copy link
Contributor

Hey @ahmadabdalla, the issue was that the subnets would be deployed without the NSG property and hence remove it. The choice was to either add all subnets properties (and duplicate them), or, remove the subnet property alltogether. I did the later as it seemed to logical choice at time time (not knowing it would remove the child templates).
Let's have a call about this some time.

@rahalan rahalan moved this to Closed in Bug board Dec 11, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants